forked from DevFW-CICD/spring-petclinic
migrated to hsql 2.2.8 and fixed a couple of JPA issues
This commit is contained in:
parent
9f8acc05ad
commit
4e35adb6b0
6 changed files with 23 additions and 27 deletions
|
|
@ -1,5 +1,7 @@
|
|||
package org.springframework.samples.petclinic;
|
||||
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
|
||||
|
|
@ -12,7 +14,7 @@ import javax.persistence.MappedSuperclass;
|
|||
*/
|
||||
@MappedSuperclass
|
||||
public class BaseEntity {
|
||||
@Id
|
||||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
protected Integer id;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.Table;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
|
@ -25,7 +27,8 @@ import org.springframework.beans.support.PropertyComparator;
|
|||
@Entity @Table(name="vets")
|
||||
public class Vet extends Person {
|
||||
|
||||
@ManyToMany
|
||||
@ManyToMany @JoinTable (name="vet_specialties",joinColumns = @JoinColumn(name = "vet_id"),
|
||||
inverseJoinColumns= @JoinColumn(name = "specialty_id"))
|
||||
private Set<Specialty> specialties;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import org.springframework.dao.DataAccessException;
|
|||
* @author Mike Keith
|
||||
* @author Rod Johnson
|
||||
* @author Sam Brannen
|
||||
* @author Michael Isvy
|
||||
* @since 22.4.2006
|
||||
*/
|
||||
@Repository
|
||||
|
|
@ -65,27 +66,16 @@ public class EntityManagerClinic implements Clinic {
|
|||
}
|
||||
|
||||
public void storeOwner(Owner owner) {
|
||||
// Consider returning the persistent object here, for exposing
|
||||
// a newly assigned id using any persistence provider...
|
||||
Owner merged = this.em.merge(owner);
|
||||
this.em.flush();
|
||||
owner.setId(merged.getId());
|
||||
this.em.merge(owner);
|
||||
|
||||
}
|
||||
|
||||
public void storePet(Pet pet) {
|
||||
// Consider returning the persistent object here, for exposing
|
||||
// a newly assigned id using any persistence provider...
|
||||
Pet merged = this.em.merge(pet);
|
||||
this.em.flush();
|
||||
pet.setId(merged.getId());
|
||||
this.em.merge(pet);
|
||||
}
|
||||
|
||||
public void storeVisit(Visit visit) {
|
||||
// Consider returning the persistent object here, for exposing
|
||||
// a newly assigned id using any persistence provider...
|
||||
Visit merged = this.em.merge(visit);
|
||||
this.em.flush();
|
||||
visit.setId(merged.getId());
|
||||
this.em.merge(visit);
|
||||
}
|
||||
|
||||
public void deletePet(int id) throws DataAccessException {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue