HHH-12361 - In the User Guide, omit constructors and equals/hashCode for brevity
This commit is contained in:
parent
8bd79b29cf
commit
870a033a52
|
@ -829,7 +829,12 @@ as illustrated by the following example.
|
|||
====
|
||||
[source, JAVA, indent=0]
|
||||
----
|
||||
include::{sourcedir}/CascadeOnDeleteTest.java[tags=pc-cascade-on-delete-mapping-example]
|
||||
include::{sourcedir}/CascadeOnDeleteTest.java[tags=pc-cascade-on-delete-mapping-Person-example]
|
||||
----
|
||||
|
||||
[source, JAVA, indent=0]
|
||||
----
|
||||
include::{sourcedir}/CascadeOnDeleteTest.java[tags=pc-cascade-on-delete-mapping-Phone-example]
|
||||
----
|
||||
|
||||
[source, SQL, indent=0]
|
||||
|
|
|
@ -71,9 +71,14 @@ public class ManyToManyBidirectionalTest extends BaseEntityManagerFunctionalTest
|
|||
|
||||
@NaturalId
|
||||
private String registrationNumber;
|
||||
|
||||
@ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
|
||||
private List<Address> addresses = new ArrayList<>();
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::associations-many-to-many-bidirectional-example[]
|
||||
|
||||
public Person() {
|
||||
}
|
||||
|
||||
|
@ -85,6 +90,7 @@ public class ManyToManyBidirectionalTest extends BaseEntityManagerFunctionalTest
|
|||
return addresses;
|
||||
}
|
||||
|
||||
//tag::associations-many-to-many-bidirectional-example[]
|
||||
public void addAddress(Address address) {
|
||||
addresses.add( address );
|
||||
address.getOwners().add( this );
|
||||
|
@ -130,6 +136,10 @@ public class ManyToManyBidirectionalTest extends BaseEntityManagerFunctionalTest
|
|||
@ManyToMany(mappedBy = "addresses")
|
||||
private List<Person> owners = new ArrayList<>();
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::associations-many-to-many-bidirectional-example[]
|
||||
|
||||
public Address() {
|
||||
}
|
||||
|
||||
|
@ -159,6 +169,7 @@ public class ManyToManyBidirectionalTest extends BaseEntityManagerFunctionalTest
|
|||
return owners;
|
||||
}
|
||||
|
||||
//tag::associations-many-to-many-bidirectional-example[]
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if ( this == o ) {
|
||||
|
|
|
@ -81,9 +81,17 @@ public class ManyToManyBidirectionalWithLinkEntityTest extends BaseEntityManager
|
|||
@NaturalId
|
||||
private String registrationNumber;
|
||||
|
||||
@OneToMany(mappedBy = "person", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
@OneToMany(
|
||||
mappedBy = "person",
|
||||
cascade = CascadeType.ALL,
|
||||
orphanRemoval = true
|
||||
)
|
||||
private List<PersonAddress> addresses = new ArrayList<>();
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::associations-many-to-many-bidirectional-with-link-entity-example[]
|
||||
|
||||
public Person() {
|
||||
}
|
||||
|
||||
|
@ -99,6 +107,7 @@ public class ManyToManyBidirectionalWithLinkEntityTest extends BaseEntityManager
|
|||
return addresses;
|
||||
}
|
||||
|
||||
//tag::associations-many-to-many-bidirectional-with-link-entity-example[]
|
||||
public void addAddress(Address address) {
|
||||
PersonAddress personAddress = new PersonAddress( this, address );
|
||||
addresses.add( personAddress );
|
||||
|
@ -142,6 +151,10 @@ public class ManyToManyBidirectionalWithLinkEntityTest extends BaseEntityManager
|
|||
@ManyToOne
|
||||
private Address address;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::associations-many-to-many-bidirectional-with-link-entity-example[]
|
||||
|
||||
public PersonAddress() {
|
||||
}
|
||||
|
||||
|
@ -166,6 +179,7 @@ public class ManyToManyBidirectionalWithLinkEntityTest extends BaseEntityManager
|
|||
this.address = address;
|
||||
}
|
||||
|
||||
//tag::associations-many-to-many-bidirectional-with-link-entity-example[]
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if ( this == o ) {
|
||||
|
@ -199,9 +213,17 @@ public class ManyToManyBidirectionalWithLinkEntityTest extends BaseEntityManager
|
|||
|
||||
private String postalCode;
|
||||
|
||||
@OneToMany(mappedBy = "address", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
@OneToMany(
|
||||
mappedBy = "address",
|
||||
cascade = CascadeType.ALL,
|
||||
orphanRemoval = true
|
||||
)
|
||||
private List<PersonAddress> owners = new ArrayList<>();
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::associations-many-to-many-bidirectional-with-link-entity-example[]
|
||||
|
||||
public Address() {
|
||||
}
|
||||
|
||||
|
@ -231,6 +253,7 @@ public class ManyToManyBidirectionalWithLinkEntityTest extends BaseEntityManager
|
|||
return owners;
|
||||
}
|
||||
|
||||
//tag::associations-many-to-many-bidirectional-with-link-entity-example[]
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if ( this == o ) {
|
||||
|
|
|
@ -100,12 +100,17 @@ public class ManyToManyUnidirectionalTest extends BaseEntityManagerFunctionalTes
|
|||
@ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
|
||||
private List<Address> addresses = new ArrayList<>();
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::associations-many-to-many-unidirectional-example[]
|
||||
|
||||
public Person() {
|
||||
}
|
||||
|
||||
public List<Address> getAddresses() {
|
||||
return addresses;
|
||||
}
|
||||
//tag::associations-many-to-many-unidirectional-example[]
|
||||
}
|
||||
|
||||
@Entity(name = "Address")
|
||||
|
@ -120,6 +125,10 @@ public class ManyToManyUnidirectionalTest extends BaseEntityManagerFunctionalTes
|
|||
@Column(name = "`number`")
|
||||
private String number;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::associations-many-to-many-unidirectional-example[]
|
||||
|
||||
public Address() {
|
||||
}
|
||||
|
||||
|
@ -139,6 +148,7 @@ public class ManyToManyUnidirectionalTest extends BaseEntityManagerFunctionalTes
|
|||
public String getNumber() {
|
||||
return number;
|
||||
}
|
||||
//tag::associations-many-to-many-unidirectional-example[]
|
||||
}
|
||||
//end::associations-many-to-many-unidirectional-example[]
|
||||
}
|
||||
|
|
|
@ -58,8 +58,8 @@ public class ManyToOneTest extends BaseEntityManagerFunctionalTestCase {
|
|||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
public Person() {
|
||||
}
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
}
|
||||
|
||||
@Entity(name = "Phone")
|
||||
|
@ -78,6 +78,10 @@ public class ManyToOneTest extends BaseEntityManagerFunctionalTestCase {
|
|||
)
|
||||
private Person person;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::associations-many-to-one-example[]
|
||||
|
||||
public Phone() {
|
||||
}
|
||||
|
||||
|
@ -100,6 +104,7 @@ public class ManyToOneTest extends BaseEntityManagerFunctionalTestCase {
|
|||
public void setPerson(Person person) {
|
||||
this.person = person;
|
||||
}
|
||||
//tag::associations-many-to-one-example[]
|
||||
}
|
||||
//end::associations-many-to-one-example[]
|
||||
}
|
||||
|
|
|
@ -62,9 +62,14 @@ public class OneToManyBidirectionalTest extends BaseEntityManagerFunctionalTestC
|
|||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
@OneToMany(mappedBy = "person", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
private List<Phone> phones = new ArrayList<>();
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::associations-one-to-many-bidirectional-example[]
|
||||
|
||||
public Person() {
|
||||
}
|
||||
|
||||
|
@ -76,6 +81,7 @@ public class OneToManyBidirectionalTest extends BaseEntityManagerFunctionalTestC
|
|||
return phones;
|
||||
}
|
||||
|
||||
//tag::associations-one-to-many-bidirectional-example[]
|
||||
public void addPhone(Phone phone) {
|
||||
phones.add( phone );
|
||||
phone.setPerson( this );
|
||||
|
@ -101,6 +107,10 @@ public class OneToManyBidirectionalTest extends BaseEntityManagerFunctionalTestC
|
|||
@ManyToOne
|
||||
private Person person;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::associations-one-to-many-bidirectional-example[]
|
||||
|
||||
public Phone() {
|
||||
}
|
||||
|
||||
|
@ -124,6 +134,7 @@ public class OneToManyBidirectionalTest extends BaseEntityManagerFunctionalTestC
|
|||
this.person = person;
|
||||
}
|
||||
|
||||
//tag::associations-one-to-many-bidirectional-example[]
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if ( this == o ) {
|
||||
|
|
|
@ -59,15 +59,22 @@ public class OneToManyUnidirectionalTest extends BaseEntityManagerFunctionalTest
|
|||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
private List<Phone> phones = new ArrayList<>();
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::associations-one-to-many-unidirectional-example[]
|
||||
|
||||
public Person() {
|
||||
}
|
||||
|
||||
public List<Phone> getPhones() {
|
||||
return phones;
|
||||
}
|
||||
|
||||
//tag::associations-one-to-many-unidirectional-example[]
|
||||
}
|
||||
|
||||
@Entity(name = "Phone")
|
||||
|
@ -80,6 +87,10 @@ public class OneToManyUnidirectionalTest extends BaseEntityManagerFunctionalTest
|
|||
@Column(name = "`number`")
|
||||
private String number;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::associations-one-to-many-unidirectional-example[]
|
||||
|
||||
public Phone() {
|
||||
}
|
||||
|
||||
|
@ -94,6 +105,7 @@ public class OneToManyUnidirectionalTest extends BaseEntityManagerFunctionalTest
|
|||
public String getNumber() {
|
||||
return number;
|
||||
}
|
||||
//tag::associations-one-to-many-unidirectional-example[]
|
||||
}
|
||||
//end::associations-one-to-many-unidirectional-example[]
|
||||
}
|
||||
|
|
|
@ -64,15 +64,16 @@ public class OneToOneBidirectionalLazyTest extends BaseEntityManagerFunctionalTe
|
|||
@LazyToOne( LazyToOneOption.NO_PROXY )
|
||||
private PhoneDetails details;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::associations-one-to-one-bidirectional-lazy-example[]
|
||||
|
||||
public Phone() {
|
||||
}
|
||||
|
||||
public Phone(String number) {
|
||||
this.number = number;
|
||||
}
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::associations-one-to-one-bidirectional-lazy-example[]
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
|
@ -86,6 +87,7 @@ public class OneToOneBidirectionalLazyTest extends BaseEntityManagerFunctionalTe
|
|||
return details;
|
||||
}
|
||||
|
||||
//tag::associations-one-to-one-bidirectional-lazy-example[]
|
||||
public void addDetails(PhoneDetails details) {
|
||||
details.setPhone( this );
|
||||
this.details = details;
|
||||
|
@ -97,7 +99,6 @@ public class OneToOneBidirectionalLazyTest extends BaseEntityManagerFunctionalTe
|
|||
this.details = null;
|
||||
}
|
||||
}
|
||||
//tag::associations-one-to-one-bidirectional-lazy-example[]
|
||||
}
|
||||
|
||||
@Entity(name = "PhoneDetails")
|
||||
|
@ -115,6 +116,10 @@ public class OneToOneBidirectionalLazyTest extends BaseEntityManagerFunctionalTe
|
|||
@JoinColumn(name = "phone_id")
|
||||
private Phone phone;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::associations-one-to-one-bidirectional-lazy-example[]
|
||||
|
||||
public PhoneDetails() {
|
||||
}
|
||||
|
||||
|
@ -124,8 +129,6 @@ public class OneToOneBidirectionalLazyTest extends BaseEntityManagerFunctionalTe
|
|||
}
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::associations-one-to-one-bidirectional-lazy-example[]
|
||||
|
||||
public String getProvider() {
|
||||
return provider;
|
||||
}
|
||||
|
|
|
@ -94,9 +94,18 @@ public class OneToOneBidirectionalTest extends BaseEntityManagerFunctionalTestCa
|
|||
@Column(name = "`number`")
|
||||
private String number;
|
||||
|
||||
@OneToOne(mappedBy = "phone", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
|
||||
@OneToOne(
|
||||
mappedBy = "phone",
|
||||
cascade = CascadeType.ALL,
|
||||
orphanRemoval = true,
|
||||
fetch = FetchType.LAZY
|
||||
)
|
||||
private PhoneDetails details;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::associations-one-to-one-bidirectional-example[]
|
||||
|
||||
public Phone() {
|
||||
}
|
||||
|
||||
|
@ -116,6 +125,7 @@ public class OneToOneBidirectionalTest extends BaseEntityManagerFunctionalTestCa
|
|||
return details;
|
||||
}
|
||||
|
||||
//tag::associations-one-to-one-bidirectional-example[]
|
||||
public void addDetails(PhoneDetails details) {
|
||||
details.setPhone( this );
|
||||
this.details = details;
|
||||
|
@ -144,6 +154,10 @@ public class OneToOneBidirectionalTest extends BaseEntityManagerFunctionalTestCa
|
|||
@JoinColumn(name = "phone_id")
|
||||
private Phone phone;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::associations-one-to-one-bidirectional-example[]
|
||||
|
||||
public PhoneDetails() {
|
||||
}
|
||||
|
||||
|
@ -171,6 +185,7 @@ public class OneToOneBidirectionalTest extends BaseEntityManagerFunctionalTestCa
|
|||
public void setPhone(Phone phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
//tag::associations-one-to-one-bidirectional-example[]
|
||||
}
|
||||
//end::associations-one-to-one-bidirectional-example[]
|
||||
}
|
||||
|
|
|
@ -59,6 +59,10 @@ public class OneToOneUnidirectionalTest extends BaseEntityManagerFunctionalTestC
|
|||
@JoinColumn(name = "details_id")
|
||||
private PhoneDetails details;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::associations-one-to-one-unidirectional-example[]
|
||||
|
||||
public Phone() {
|
||||
}
|
||||
|
||||
|
@ -81,6 +85,7 @@ public class OneToOneUnidirectionalTest extends BaseEntityManagerFunctionalTestC
|
|||
public void setDetails(PhoneDetails details) {
|
||||
this.details = details;
|
||||
}
|
||||
//tag::associations-one-to-one-unidirectional-example[]
|
||||
}
|
||||
|
||||
@Entity(name = "PhoneDetails")
|
||||
|
@ -94,6 +99,10 @@ public class OneToOneUnidirectionalTest extends BaseEntityManagerFunctionalTestC
|
|||
|
||||
private String technology;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::associations-one-to-one-unidirectional-example[]
|
||||
|
||||
public PhoneDetails() {
|
||||
}
|
||||
|
||||
|
@ -113,6 +122,7 @@ public class OneToOneUnidirectionalTest extends BaseEntityManagerFunctionalTestC
|
|||
public void setTechnology(String technology) {
|
||||
this.technology = technology;
|
||||
}
|
||||
//tag::associations-one-to-one-unidirectional-example[]
|
||||
}
|
||||
//end::associations-one-to-one-unidirectional-example[]
|
||||
}
|
||||
|
|
|
@ -164,6 +164,10 @@ public class NonStrictReadWriteCacheTest extends BaseEntityManagerFunctionalTest
|
|||
@Version
|
||||
private int version;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::caching-entity-mapping-example[]
|
||||
|
||||
public Phone() {}
|
||||
|
||||
public Phone(String mobile) {
|
||||
|
@ -185,6 +189,7 @@ public class NonStrictReadWriteCacheTest extends BaseEntityManagerFunctionalTest
|
|||
public void setPerson(Person person) {
|
||||
this.person = person;
|
||||
}
|
||||
//tag::caching-entity-mapping-example[]
|
||||
}
|
||||
//end::caching-entity-mapping-example[]
|
||||
}
|
||||
|
|
|
@ -267,7 +267,11 @@ public class SecondLevelCacheTest extends BaseEntityManagerFunctionalTestCase {
|
|||
@Column(name = "code", unique = true)
|
||||
private String code;
|
||||
|
||||
public Person() {}
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::caching-entity-natural-id-mapping-example[]
|
||||
|
||||
public Person() {}
|
||||
|
||||
public Person(String name) {
|
||||
this.name = name;
|
||||
|
@ -292,6 +296,7 @@ public class SecondLevelCacheTest extends BaseEntityManagerFunctionalTestCase {
|
|||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
//tag::caching-entity-natural-id-mapping-example[]
|
||||
}
|
||||
//end::caching-entity-natural-id-mapping-example[]
|
||||
}
|
||||
|
|
|
@ -51,8 +51,13 @@ public class ArrayTest extends BaseEntityManagerFunctionalTestCase {
|
|||
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
private String[] phones;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::collections-array-binary-example[]
|
||||
|
||||
public Person() {
|
||||
}
|
||||
|
||||
|
@ -67,6 +72,7 @@ public class ArrayTest extends BaseEntityManagerFunctionalTestCase {
|
|||
public void setPhones(String[] phones) {
|
||||
this.phones = phones;
|
||||
}
|
||||
//tag::collections-array-binary-example[]
|
||||
}
|
||||
//end::collections-array-binary-example[]
|
||||
}
|
||||
|
|
|
@ -90,9 +90,14 @@ public class BasicTypeElementCollectionTest extends BaseEntityManagerFunctionalT
|
|||
@ElementCollection
|
||||
private List<String> phones = new ArrayList<>();
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::collections-collection-proxy-entity-example[]
|
||||
|
||||
public List<String> getPhones() {
|
||||
return phones;
|
||||
}
|
||||
//tag::collections-collection-proxy-entity-example[]
|
||||
}
|
||||
//end::collections-collection-proxy-entity-example[]
|
||||
}
|
||||
|
|
|
@ -56,9 +56,14 @@ public class BidirectionalBagTest extends BaseEntityManagerFunctionalTestCase {
|
|||
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
@OneToMany(mappedBy = "person", cascade = CascadeType.ALL)
|
||||
private List<Phone> phones = new ArrayList<>();
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::collections-bidirectional-bag-example[]
|
||||
|
||||
public Person() {
|
||||
}
|
||||
|
||||
|
@ -70,6 +75,7 @@ public class BidirectionalBagTest extends BaseEntityManagerFunctionalTestCase {
|
|||
return phones;
|
||||
}
|
||||
|
||||
//tag::collections-bidirectional-bag-example[]
|
||||
public void addPhone(Phone phone) {
|
||||
phones.add( phone );
|
||||
phone.setPerson( this );
|
||||
|
@ -96,6 +102,10 @@ public class BidirectionalBagTest extends BaseEntityManagerFunctionalTestCase {
|
|||
@ManyToOne
|
||||
private Person person;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::collections-bidirectional-bag-example[]
|
||||
|
||||
public Phone() {
|
||||
}
|
||||
|
||||
|
@ -125,6 +135,7 @@ public class BidirectionalBagTest extends BaseEntityManagerFunctionalTestCase {
|
|||
this.person = person;
|
||||
}
|
||||
|
||||
//tag::collections-bidirectional-bag-example[]
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if ( this == o ) {
|
||||
|
|
|
@ -74,6 +74,10 @@ public class BidirectionalMapTest extends BaseEntityManagerFunctionalTestCase {
|
|||
@MapKeyEnumerated
|
||||
private Map<PhoneType, Phone> phoneRegister = new HashMap<>();
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::collections-map-bidirectional-example[]
|
||||
|
||||
public Person() {
|
||||
}
|
||||
|
||||
|
@ -85,6 +89,7 @@ public class BidirectionalMapTest extends BaseEntityManagerFunctionalTestCase {
|
|||
return phoneRegister;
|
||||
}
|
||||
|
||||
//tag::collections-map-bidirectional-example[]
|
||||
public void addPhone(Phone phone) {
|
||||
phone.setPerson( this );
|
||||
phoneRegister.put( phone.getType(), phone );
|
||||
|
@ -108,6 +113,10 @@ public class BidirectionalMapTest extends BaseEntityManagerFunctionalTestCase {
|
|||
@ManyToOne
|
||||
private Person person;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::collections-map-bidirectional-example[]
|
||||
|
||||
public Phone() {
|
||||
}
|
||||
|
||||
|
@ -136,6 +145,7 @@ public class BidirectionalMapTest extends BaseEntityManagerFunctionalTestCase {
|
|||
public void setPerson(Person person) {
|
||||
this.person = person;
|
||||
}
|
||||
//tag::collections-map-bidirectional-example[]
|
||||
}
|
||||
//end::collections-map-bidirectional-example[]
|
||||
}
|
||||
|
|
|
@ -69,6 +69,10 @@ public class BidirectionalSetTest extends BaseEntityManagerFunctionalTestCase {
|
|||
@OneToMany(mappedBy = "person", cascade = CascadeType.ALL)
|
||||
private Set<Phone> phones = new HashSet<>();
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::collections-bidirectional-set-example[]
|
||||
|
||||
public Person() {
|
||||
}
|
||||
|
||||
|
@ -80,6 +84,7 @@ public class BidirectionalSetTest extends BaseEntityManagerFunctionalTestCase {
|
|||
return phones;
|
||||
}
|
||||
|
||||
//tag::collections-bidirectional-set-example[]
|
||||
public void addPhone(Phone phone) {
|
||||
phones.add( phone );
|
||||
phone.setPerson( this );
|
||||
|
@ -106,6 +111,10 @@ public class BidirectionalSetTest extends BaseEntityManagerFunctionalTestCase {
|
|||
@ManyToOne
|
||||
private Person person;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::collections-bidirectional-set-example[]
|
||||
|
||||
public Phone() {
|
||||
}
|
||||
|
||||
|
@ -135,6 +144,7 @@ public class BidirectionalSetTest extends BaseEntityManagerFunctionalTestCase {
|
|||
this.person = person;
|
||||
}
|
||||
|
||||
//tag::collections-bidirectional-set-example[]
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if ( this == o ) {
|
||||
|
|
|
@ -78,6 +78,10 @@ public class ElementCollectionMapTest extends BaseEntityManagerFunctionalTestCas
|
|||
@Column(name = "since")
|
||||
private Map<Phone, Date> phoneRegister = new HashMap<>();
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::collections-map-value-type-entity-key-example[]
|
||||
|
||||
public Person() {}
|
||||
|
||||
public Person(Long id) {
|
||||
|
@ -87,6 +91,7 @@ public class ElementCollectionMapTest extends BaseEntityManagerFunctionalTestCas
|
|||
public Map<Phone, Date> getPhoneRegister() {
|
||||
return phoneRegister;
|
||||
}
|
||||
//tag::collections-map-value-type-entity-key-example[]
|
||||
}
|
||||
|
||||
@Embeddable
|
||||
|
@ -97,6 +102,10 @@ public class ElementCollectionMapTest extends BaseEntityManagerFunctionalTestCas
|
|||
@Column(name = "`number`")
|
||||
private String number;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::collections-map-value-type-entity-key-example[]
|
||||
|
||||
public Phone() {
|
||||
}
|
||||
|
||||
|
@ -112,6 +121,7 @@ public class ElementCollectionMapTest extends BaseEntityManagerFunctionalTestCas
|
|||
public String getNumber() {
|
||||
return number;
|
||||
}
|
||||
//tag::collections-map-value-type-entity-key-example[]
|
||||
}
|
||||
//end::collections-map-value-type-entity-key-example[]
|
||||
}
|
||||
|
|
|
@ -55,9 +55,14 @@ public class EmbeddableTypeElementCollectionTest extends BaseEntityManagerFuncti
|
|||
@ElementCollection
|
||||
private List<Phone> phones = new ArrayList<>();
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::collections-embeddable-type-collection-lifecycle-entity-example[]
|
||||
|
||||
public List<Phone> getPhones() {
|
||||
return phones;
|
||||
}
|
||||
//tag::collections-embeddable-type-collection-lifecycle-entity-example[]
|
||||
}
|
||||
|
||||
@Embeddable
|
||||
|
@ -68,6 +73,10 @@ public class EmbeddableTypeElementCollectionTest extends BaseEntityManagerFuncti
|
|||
@Column(name = "`number`")
|
||||
private String number;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::collections-embeddable-type-collection-lifecycle-entity-example[]
|
||||
|
||||
public Phone() {
|
||||
}
|
||||
|
||||
|
@ -83,6 +92,7 @@ public class EmbeddableTypeElementCollectionTest extends BaseEntityManagerFuncti
|
|||
public String getNumber() {
|
||||
return number;
|
||||
}
|
||||
//tag::collections-embeddable-type-collection-lifecycle-entity-example[]
|
||||
}
|
||||
//end::collections-embeddable-type-collection-lifecycle-entity-example[]
|
||||
}
|
||||
|
|
|
@ -147,6 +147,10 @@ public class MapKeyTypeTest extends BaseEntityManagerFunctionalTestCase {
|
|||
@Column(name = "phone_number")
|
||||
private Map<Date, Integer> callRegister = new HashMap<>();
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::collections-map-custom-key-type-mapping-example[]
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
@ -154,7 +158,7 @@ public class MapKeyTypeTest extends BaseEntityManagerFunctionalTestCase {
|
|||
public Map<Date, Integer> getCallRegister() {
|
||||
return callRegister;
|
||||
}
|
||||
//tag::collections-map-custom-key-type-mapping-example[]
|
||||
}
|
||||
|
||||
//end::collections-map-custom-key-type-mapping-example[]
|
||||
}
|
||||
|
|
|
@ -80,8 +80,13 @@ public class OrderedBySQLTest extends BaseEntityManagerFunctionalTestCase {
|
|||
|
||||
private String name;
|
||||
|
||||
@OneToMany(mappedBy = "person", cascade = CascadeType.ALL)
|
||||
@org.hibernate.annotations.OrderBy(clause = "CHAR_LENGTH(name) DESC")
|
||||
@OneToMany(
|
||||
mappedBy = "person",
|
||||
cascade = CascadeType.ALL
|
||||
)
|
||||
@org.hibernate.annotations.OrderBy(
|
||||
clause = "CHAR_LENGTH(name) DESC"
|
||||
)
|
||||
private List<Article> articles = new ArrayList<>();
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
@ -128,6 +133,9 @@ public class OrderedBySQLTest extends BaseEntityManagerFunctionalTestCase {
|
|||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
private Person person;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
//end::collections-customizing-ordered-by-sql-clause-mapping-example[]
|
||||
|
||||
private Article() {
|
||||
}
|
||||
|
||||
|
@ -136,9 +144,6 @@ public class OrderedBySQLTest extends BaseEntityManagerFunctionalTestCase {
|
|||
this.content = content;
|
||||
}
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
//end::collections-customizing-ordered-by-sql-clause-mapping-example[]
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
|
|
@ -55,9 +55,14 @@ public class UnidirectionalBagTest extends BaseEntityManagerFunctionalTestCase {
|
|||
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL)
|
||||
private List<Phone> phones = new ArrayList<>();
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::collections-unidirectional-bag-example[]
|
||||
|
||||
public Person() {
|
||||
}
|
||||
|
||||
|
@ -68,6 +73,7 @@ public class UnidirectionalBagTest extends BaseEntityManagerFunctionalTestCase {
|
|||
public List<Phone> getPhones() {
|
||||
return phones;
|
||||
}
|
||||
//tag::collections-unidirectional-bag-example[]
|
||||
}
|
||||
|
||||
@Entity(name = "Phone")
|
||||
|
@ -81,6 +87,10 @@ public class UnidirectionalBagTest extends BaseEntityManagerFunctionalTestCase {
|
|||
@Column(name = "`number`")
|
||||
private String number;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::collections-unidirectional-bag-example[]
|
||||
|
||||
public Phone() {
|
||||
}
|
||||
|
||||
|
@ -101,6 +111,7 @@ public class UnidirectionalBagTest extends BaseEntityManagerFunctionalTestCase {
|
|||
public String getNumber() {
|
||||
return number;
|
||||
}
|
||||
//tag::collections-unidirectional-bag-example[]
|
||||
}
|
||||
//end::collections-unidirectional-bag-example[]
|
||||
}
|
||||
|
|
|
@ -75,6 +75,10 @@ public class UnidirectionalComparatorSortedSetTest extends BaseEntityManagerFunc
|
|||
@SortComparator(ReverseComparator.class)
|
||||
private SortedSet<Phone> phones = new TreeSet<>();
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::collections-unidirectional-sorted-set-custom-comparator-example[]
|
||||
|
||||
public Person() {
|
||||
}
|
||||
|
||||
|
@ -85,9 +89,11 @@ public class UnidirectionalComparatorSortedSetTest extends BaseEntityManagerFunc
|
|||
public Set<Phone> getPhones() {
|
||||
return phones;
|
||||
}
|
||||
//tag::collections-unidirectional-sorted-set-custom-comparator-example[]
|
||||
}
|
||||
|
||||
public static class ReverseComparator implements Comparator<Phone> {
|
||||
|
||||
@Override
|
||||
public int compare(Phone o1, Phone o2) {
|
||||
return o2.compareTo( o1 );
|
||||
|
@ -106,6 +112,10 @@ public class UnidirectionalComparatorSortedSetTest extends BaseEntityManagerFunc
|
|||
@Column(name = "`number`")
|
||||
private String number;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::collections-unidirectional-sorted-set-custom-comparator-example[]
|
||||
|
||||
public Phone() {
|
||||
}
|
||||
|
||||
|
@ -127,6 +137,7 @@ public class UnidirectionalComparatorSortedSetTest extends BaseEntityManagerFunc
|
|||
return number;
|
||||
}
|
||||
|
||||
//tag::collections-unidirectional-sorted-set-custom-comparator-example[]
|
||||
@Override
|
||||
public int compareTo(Phone o) {
|
||||
return number.compareTo( o.getNumber() );
|
||||
|
|
|
@ -77,13 +77,17 @@ public class UnidirectionalMapTest extends BaseEntityManagerFunctionalTestCase {
|
|||
|
||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
@JoinTable(
|
||||
name = "phone_register",
|
||||
joinColumns = @JoinColumn(name = "phone_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "person_id"))
|
||||
name = "phone_register",
|
||||
joinColumns = @JoinColumn(name = "phone_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "person_id"))
|
||||
@MapKey(name = "since")
|
||||
@MapKeyTemporal(TemporalType.TIMESTAMP)
|
||||
private Map<Date, Phone> phoneRegister = new HashMap<>();
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::collections-map-unidirectional-example[]
|
||||
|
||||
public Person() {
|
||||
}
|
||||
|
||||
|
@ -95,6 +99,7 @@ public class UnidirectionalMapTest extends BaseEntityManagerFunctionalTestCase {
|
|||
return phoneRegister;
|
||||
}
|
||||
|
||||
//tag::collections-map-unidirectional-example[]
|
||||
public void addPhone(Phone phone) {
|
||||
phoneRegister.put( phone.getSince(), phone );
|
||||
}
|
||||
|
@ -114,6 +119,10 @@ public class UnidirectionalMapTest extends BaseEntityManagerFunctionalTestCase {
|
|||
|
||||
private Date since;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::collections-map-unidirectional-example[]
|
||||
|
||||
public Phone() {
|
||||
}
|
||||
|
||||
|
@ -134,6 +143,7 @@ public class UnidirectionalMapTest extends BaseEntityManagerFunctionalTestCase {
|
|||
public Date getSince() {
|
||||
return since;
|
||||
}
|
||||
//tag::collections-map-unidirectional-example[]
|
||||
}
|
||||
//end::collections-map-unidirectional-example[]
|
||||
}
|
||||
|
|
|
@ -54,10 +54,15 @@ public class UnidirectionalOrderedByListTest extends BaseEntityManagerFunctional
|
|||
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL)
|
||||
@OrderBy("number")
|
||||
private List<Phone> phones = new ArrayList<>();
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::collections-unidirectional-ordered-list-order-by-example[]
|
||||
|
||||
public Person() {
|
||||
}
|
||||
|
||||
|
@ -68,6 +73,7 @@ public class UnidirectionalOrderedByListTest extends BaseEntityManagerFunctional
|
|||
public List<Phone> getPhones() {
|
||||
return phones;
|
||||
}
|
||||
//tag::collections-unidirectional-ordered-list-order-by-example[]
|
||||
}
|
||||
|
||||
@Entity(name = "Phone")
|
||||
|
@ -81,6 +87,10 @@ public class UnidirectionalOrderedByListTest extends BaseEntityManagerFunctional
|
|||
@Column(name = "`number`")
|
||||
private String number;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::collections-unidirectional-ordered-list-order-by-example[]
|
||||
|
||||
public Phone() {
|
||||
}
|
||||
|
||||
|
@ -101,6 +111,7 @@ public class UnidirectionalOrderedByListTest extends BaseEntityManagerFunctional
|
|||
public String getNumber() {
|
||||
return number;
|
||||
}
|
||||
//tag::collections-unidirectional-ordered-list-order-by-example[]
|
||||
}
|
||||
//end::collections-unidirectional-ordered-list-order-by-example[]
|
||||
}
|
||||
|
|
|
@ -64,9 +64,13 @@ public class UnidirectionalSetTest extends BaseEntityManagerFunctionalTestCase {
|
|||
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL)
|
||||
private Set<Phone> phones = new HashSet<>();
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
//end::collections-unidirectional-set-example[]
|
||||
|
||||
public Person() {
|
||||
}
|
||||
|
||||
|
@ -77,6 +81,7 @@ public class UnidirectionalSetTest extends BaseEntityManagerFunctionalTestCase {
|
|||
public Set<Phone> getPhones() {
|
||||
return phones;
|
||||
}
|
||||
//tag::collections-unidirectional-set-example[]
|
||||
}
|
||||
|
||||
@Entity(name = "Phone")
|
||||
|
@ -91,6 +96,10 @@ public class UnidirectionalSetTest extends BaseEntityManagerFunctionalTestCase {
|
|||
@Column(name = "`number`")
|
||||
private String number;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::collections-unidirectional-set-example[]
|
||||
|
||||
public Phone() {
|
||||
}
|
||||
|
||||
|
@ -112,6 +121,7 @@ public class UnidirectionalSetTest extends BaseEntityManagerFunctionalTestCase {
|
|||
return number;
|
||||
}
|
||||
|
||||
//tag::collections-unidirectional-set-example[]
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if ( this == o ) {
|
||||
|
|
|
@ -69,10 +69,15 @@ public class UnidirectionalSortedSetTest extends BaseEntityManagerFunctionalTest
|
|||
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL)
|
||||
@SortNatural
|
||||
private SortedSet<Phone> phones = new TreeSet<>();
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::collections-unidirectional-sorted-set-natural-comparator-example[]
|
||||
|
||||
public Person() {
|
||||
}
|
||||
|
||||
|
@ -83,6 +88,7 @@ public class UnidirectionalSortedSetTest extends BaseEntityManagerFunctionalTest
|
|||
public Set<Phone> getPhones() {
|
||||
return phones;
|
||||
}
|
||||
//tag::collections-unidirectional-sorted-set-natural-comparator-example[]
|
||||
}
|
||||
|
||||
@Entity(name = "Phone")
|
||||
|
@ -97,6 +103,10 @@ public class UnidirectionalSortedSetTest extends BaseEntityManagerFunctionalTest
|
|||
@Column(name = "`number`")
|
||||
private String number;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::collections-unidirectional-sorted-set-natural-comparator-example[]
|
||||
|
||||
public Phone() {
|
||||
}
|
||||
|
||||
|
@ -118,6 +128,7 @@ public class UnidirectionalSortedSetTest extends BaseEntityManagerFunctionalTest
|
|||
return number;
|
||||
}
|
||||
|
||||
//tag::collections-unidirectional-sorted-set-natural-comparator-example[]
|
||||
@Override
|
||||
public int compareTo(Phone o) {
|
||||
return number.compareTo( o.getNumber() );
|
||||
|
|
|
@ -14,6 +14,10 @@ public abstract class BaseEntity {
|
|||
|
||||
private Timestamp updatedOn;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::events-default-listener-mapping-example[]
|
||||
|
||||
public Timestamp getCreatedOn() {
|
||||
return createdOn;
|
||||
}
|
||||
|
@ -29,6 +33,7 @@ public abstract class BaseEntity {
|
|||
void setUpdatedOn(Timestamp updatedOn) {
|
||||
this.updatedOn = updatedOn;
|
||||
}
|
||||
//tag::events-default-listener-mapping-example[]
|
||||
}
|
||||
//end::events-default-listener-mapping-example[]
|
||||
|
||||
|
|
|
@ -79,7 +79,6 @@ public class DirectVsQueryFetchingTest extends BaseEntityManagerFunctionalTestCa
|
|||
//Getters and setters omitted for brevity
|
||||
}
|
||||
|
||||
//tag::fetching-direct-vs-query-domain-model-example[]
|
||||
@Entity(name = "Employee")
|
||||
public static class Employee {
|
||||
|
||||
|
|
|
@ -174,6 +174,10 @@ public class AutoFlushTest extends BaseEntityManagerFunctionalTestCase {
|
|||
|
||||
private String name;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::flushing-auto-flush-jpql-entity-example[]
|
||||
|
||||
public Person() {}
|
||||
|
||||
public Person(String name) {
|
||||
|
@ -187,7 +191,7 @@ public class AutoFlushTest extends BaseEntityManagerFunctionalTestCase {
|
|||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
//tag::flushing-auto-flush-jpql-entity-example[]
|
||||
}
|
||||
|
||||
@Entity(name = "Advertisement")
|
||||
|
@ -199,6 +203,10 @@ public class AutoFlushTest extends BaseEntityManagerFunctionalTestCase {
|
|||
|
||||
private String title;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::flushing-auto-flush-jpql-entity-example[]
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -214,6 +222,7 @@ public class AutoFlushTest extends BaseEntityManagerFunctionalTestCase {
|
|||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
//tag::flushing-auto-flush-jpql-entity-example[]
|
||||
}
|
||||
//end::flushing-auto-flush-jpql-entity-example[]
|
||||
}
|
||||
|
|
|
@ -120,6 +120,10 @@ public class DiscriminatorNotNullSingleTableTest extends BaseEntityManagerFuncti
|
|||
|
||||
private BigDecimal interestRate;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::entity-inheritance-single-table-discriminator-value-example[]
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -151,6 +155,7 @@ public class DiscriminatorNotNullSingleTableTest extends BaseEntityManagerFuncti
|
|||
public void setInterestRate(BigDecimal interestRate) {
|
||||
this.interestRate = interestRate;
|
||||
}
|
||||
//tag::entity-inheritance-single-table-discriminator-value-example[]
|
||||
}
|
||||
|
||||
@Entity(name = "DebitAccount")
|
||||
|
@ -159,6 +164,10 @@ public class DiscriminatorNotNullSingleTableTest extends BaseEntityManagerFuncti
|
|||
|
||||
private BigDecimal overdraftFee;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::entity-inheritance-single-table-discriminator-value-example[]
|
||||
|
||||
public BigDecimal getOverdraftFee() {
|
||||
return overdraftFee;
|
||||
}
|
||||
|
@ -166,6 +175,7 @@ public class DiscriminatorNotNullSingleTableTest extends BaseEntityManagerFuncti
|
|||
public void setOverdraftFee(BigDecimal overdraftFee) {
|
||||
this.overdraftFee = overdraftFee;
|
||||
}
|
||||
//tag::entity-inheritance-single-table-discriminator-value-example[]
|
||||
}
|
||||
|
||||
@Entity(name = "CreditAccount")
|
||||
|
@ -174,6 +184,10 @@ public class DiscriminatorNotNullSingleTableTest extends BaseEntityManagerFuncti
|
|||
|
||||
private BigDecimal creditLimit;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::entity-inheritance-single-table-discriminator-value-example[]
|
||||
|
||||
public BigDecimal getCreditLimit() {
|
||||
return creditLimit;
|
||||
}
|
||||
|
@ -181,6 +195,7 @@ public class DiscriminatorNotNullSingleTableTest extends BaseEntityManagerFuncti
|
|||
public void setCreditLimit(BigDecimal creditLimit) {
|
||||
this.creditLimit = creditLimit;
|
||||
}
|
||||
//tag::entity-inheritance-single-table-discriminator-value-example[]
|
||||
}
|
||||
|
||||
@Entity(name = "OtherAccount")
|
||||
|
@ -189,6 +204,10 @@ public class DiscriminatorNotNullSingleTableTest extends BaseEntityManagerFuncti
|
|||
|
||||
private boolean active;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::entity-inheritance-single-table-discriminator-value-example[]
|
||||
|
||||
public boolean isActive() {
|
||||
return active;
|
||||
}
|
||||
|
@ -196,6 +215,7 @@ public class DiscriminatorNotNullSingleTableTest extends BaseEntityManagerFuncti
|
|||
public void setActive(boolean active) {
|
||||
this.active = active;
|
||||
}
|
||||
//tag::entity-inheritance-single-table-discriminator-value-example[]
|
||||
}
|
||||
//end::entity-inheritance-single-table-discriminator-value-example[]
|
||||
}
|
||||
|
|
|
@ -74,6 +74,10 @@ public class JoinTablePrimaryKeyJoinColumnTest extends BaseEntityManagerFunction
|
|||
|
||||
private BigDecimal interestRate;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::entity-inheritance-joined-table-primary-key-join-column-example[]
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -105,6 +109,7 @@ public class JoinTablePrimaryKeyJoinColumnTest extends BaseEntityManagerFunction
|
|||
public void setInterestRate(BigDecimal interestRate) {
|
||||
this.interestRate = interestRate;
|
||||
}
|
||||
//tag::entity-inheritance-joined-table-primary-key-join-column-example[]
|
||||
}
|
||||
|
||||
@Entity(name = "DebitAccount")
|
||||
|
@ -113,6 +118,10 @@ public class JoinTablePrimaryKeyJoinColumnTest extends BaseEntityManagerFunction
|
|||
|
||||
private BigDecimal overdraftFee;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::entity-inheritance-joined-table-primary-key-join-column-example[]
|
||||
|
||||
public BigDecimal getOverdraftFee() {
|
||||
return overdraftFee;
|
||||
}
|
||||
|
@ -120,6 +129,7 @@ public class JoinTablePrimaryKeyJoinColumnTest extends BaseEntityManagerFunction
|
|||
public void setOverdraftFee(BigDecimal overdraftFee) {
|
||||
this.overdraftFee = overdraftFee;
|
||||
}
|
||||
//tag::entity-inheritance-joined-table-primary-key-join-column-example[]
|
||||
}
|
||||
|
||||
@Entity(name = "CreditAccount")
|
||||
|
@ -128,6 +138,10 @@ public class JoinTablePrimaryKeyJoinColumnTest extends BaseEntityManagerFunction
|
|||
|
||||
private BigDecimal creditLimit;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::entity-inheritance-joined-table-primary-key-join-column-example[]
|
||||
|
||||
public BigDecimal getCreditLimit() {
|
||||
return creditLimit;
|
||||
}
|
||||
|
@ -135,6 +149,7 @@ public class JoinTablePrimaryKeyJoinColumnTest extends BaseEntityManagerFunction
|
|||
public void setCreditLimit(BigDecimal creditLimit) {
|
||||
this.creditLimit = creditLimit;
|
||||
}
|
||||
//tag::entity-inheritance-joined-table-primary-key-join-column-example[]
|
||||
}
|
||||
//end::entity-inheritance-joined-table-primary-key-join-column-example[]
|
||||
}
|
||||
|
|
|
@ -76,6 +76,10 @@ public class JoinTableTest extends BaseEntityManagerFunctionalTestCase {
|
|||
|
||||
private BigDecimal interestRate;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::entity-inheritance-joined-table-example[]
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -107,6 +111,7 @@ public class JoinTableTest extends BaseEntityManagerFunctionalTestCase {
|
|||
public void setInterestRate(BigDecimal interestRate) {
|
||||
this.interestRate = interestRate;
|
||||
}
|
||||
//tag::entity-inheritance-joined-table-example[]
|
||||
}
|
||||
|
||||
@Entity(name = "DebitAccount")
|
||||
|
@ -114,6 +119,10 @@ public class JoinTableTest extends BaseEntityManagerFunctionalTestCase {
|
|||
|
||||
private BigDecimal overdraftFee;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::entity-inheritance-joined-table-example[]
|
||||
|
||||
public BigDecimal getOverdraftFee() {
|
||||
return overdraftFee;
|
||||
}
|
||||
|
@ -121,6 +130,7 @@ public class JoinTableTest extends BaseEntityManagerFunctionalTestCase {
|
|||
public void setOverdraftFee(BigDecimal overdraftFee) {
|
||||
this.overdraftFee = overdraftFee;
|
||||
}
|
||||
//tag::entity-inheritance-joined-table-example[]
|
||||
}
|
||||
|
||||
@Entity(name = "CreditAccount")
|
||||
|
@ -128,6 +138,10 @@ public class JoinTableTest extends BaseEntityManagerFunctionalTestCase {
|
|||
|
||||
private BigDecimal creditLimit;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::entity-inheritance-joined-table-example[]
|
||||
|
||||
public BigDecimal getCreditLimit() {
|
||||
return creditLimit;
|
||||
}
|
||||
|
@ -135,6 +149,7 @@ public class JoinTableTest extends BaseEntityManagerFunctionalTestCase {
|
|||
public void setCreditLimit(BigDecimal creditLimit) {
|
||||
this.creditLimit = creditLimit;
|
||||
}
|
||||
//tag::entity-inheritance-joined-table-example[]
|
||||
}
|
||||
//end::entity-inheritance-joined-table-example[]
|
||||
}
|
||||
|
|
|
@ -65,6 +65,10 @@ public class MappedSuperclassTest extends BaseEntityManagerFunctionalTestCase {
|
|||
|
||||
private BigDecimal interestRate;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::entity-inheritance-mapped-superclass-example[]
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -96,6 +100,7 @@ public class MappedSuperclassTest extends BaseEntityManagerFunctionalTestCase {
|
|||
public void setInterestRate(BigDecimal interestRate) {
|
||||
this.interestRate = interestRate;
|
||||
}
|
||||
//tag::entity-inheritance-mapped-superclass-example[]
|
||||
}
|
||||
|
||||
@Entity(name = "DebitAccount")
|
||||
|
@ -103,6 +108,10 @@ public class MappedSuperclassTest extends BaseEntityManagerFunctionalTestCase {
|
|||
|
||||
private BigDecimal overdraftFee;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::entity-inheritance-mapped-superclass-example[]
|
||||
|
||||
public BigDecimal getOverdraftFee() {
|
||||
return overdraftFee;
|
||||
}
|
||||
|
@ -110,6 +119,7 @@ public class MappedSuperclassTest extends BaseEntityManagerFunctionalTestCase {
|
|||
public void setOverdraftFee(BigDecimal overdraftFee) {
|
||||
this.overdraftFee = overdraftFee;
|
||||
}
|
||||
//tag::entity-inheritance-mapped-superclass-example[]
|
||||
}
|
||||
|
||||
@Entity(name = "CreditAccount")
|
||||
|
@ -117,6 +127,10 @@ public class MappedSuperclassTest extends BaseEntityManagerFunctionalTestCase {
|
|||
|
||||
private BigDecimal creditLimit;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::entity-inheritance-mapped-superclass-example[]
|
||||
|
||||
public BigDecimal getCreditLimit() {
|
||||
return creditLimit;
|
||||
}
|
||||
|
@ -124,6 +138,7 @@ public class MappedSuperclassTest extends BaseEntityManagerFunctionalTestCase {
|
|||
public void setCreditLimit(BigDecimal creditLimit) {
|
||||
this.creditLimit = creditLimit;
|
||||
}
|
||||
//tag::entity-inheritance-mapped-superclass-example[]
|
||||
}
|
||||
//end::entity-inheritance-mapped-superclass-example[]
|
||||
}
|
||||
|
|
|
@ -90,6 +90,10 @@ public class SingleTableDiscriminatorFormulaTest extends BaseEntityManagerFuncti
|
|||
|
||||
private BigDecimal interestRate;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::entity-inheritance-single-table-discriminator-formula-example[]
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -121,6 +125,7 @@ public class SingleTableDiscriminatorFormulaTest extends BaseEntityManagerFuncti
|
|||
public void setInterestRate(BigDecimal interestRate) {
|
||||
this.interestRate = interestRate;
|
||||
}
|
||||
//tag::entity-inheritance-single-table-discriminator-formula-example[]
|
||||
}
|
||||
|
||||
@Entity(name = "DebitAccount")
|
||||
|
@ -131,6 +136,10 @@ public class SingleTableDiscriminatorFormulaTest extends BaseEntityManagerFuncti
|
|||
|
||||
private BigDecimal overdraftFee;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::entity-inheritance-single-table-discriminator-formula-example[]
|
||||
|
||||
private DebitAccount() {
|
||||
}
|
||||
|
||||
|
@ -149,6 +158,7 @@ public class SingleTableDiscriminatorFormulaTest extends BaseEntityManagerFuncti
|
|||
public void setOverdraftFee(BigDecimal overdraftFee) {
|
||||
this.overdraftFee = overdraftFee;
|
||||
}
|
||||
//tag::entity-inheritance-single-table-discriminator-formula-example[]
|
||||
}
|
||||
|
||||
@Entity(name = "CreditAccount")
|
||||
|
@ -159,6 +169,10 @@ public class SingleTableDiscriminatorFormulaTest extends BaseEntityManagerFuncti
|
|||
|
||||
private BigDecimal creditLimit;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::entity-inheritance-single-table-discriminator-formula-example[]
|
||||
|
||||
private CreditAccount() {
|
||||
}
|
||||
|
||||
|
@ -177,6 +191,7 @@ public class SingleTableDiscriminatorFormulaTest extends BaseEntityManagerFuncti
|
|||
public void setCreditLimit(BigDecimal creditLimit) {
|
||||
this.creditLimit = creditLimit;
|
||||
}
|
||||
//tag::entity-inheritance-single-table-discriminator-formula-example[]
|
||||
}
|
||||
//end::entity-inheritance-single-table-discriminator-formula-example[]
|
||||
}
|
||||
|
|
|
@ -78,6 +78,10 @@ public class SingleTableTest extends BaseEntityManagerFunctionalTestCase {
|
|||
|
||||
private BigDecimal interestRate;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::entity-inheritance-single-table-example[]
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -109,6 +113,7 @@ public class SingleTableTest extends BaseEntityManagerFunctionalTestCase {
|
|||
public void setInterestRate(BigDecimal interestRate) {
|
||||
this.interestRate = interestRate;
|
||||
}
|
||||
//tag::entity-inheritance-single-table-example[]
|
||||
}
|
||||
|
||||
@Entity(name = "DebitAccount")
|
||||
|
@ -116,6 +121,10 @@ public class SingleTableTest extends BaseEntityManagerFunctionalTestCase {
|
|||
|
||||
private BigDecimal overdraftFee;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::entity-inheritance-single-table-example[]
|
||||
|
||||
public BigDecimal getOverdraftFee() {
|
||||
return overdraftFee;
|
||||
}
|
||||
|
@ -123,6 +132,7 @@ public class SingleTableTest extends BaseEntityManagerFunctionalTestCase {
|
|||
public void setOverdraftFee(BigDecimal overdraftFee) {
|
||||
this.overdraftFee = overdraftFee;
|
||||
}
|
||||
//tag::entity-inheritance-single-table-example[]
|
||||
}
|
||||
|
||||
@Entity(name = "CreditAccount")
|
||||
|
@ -130,6 +140,10 @@ public class SingleTableTest extends BaseEntityManagerFunctionalTestCase {
|
|||
|
||||
private BigDecimal creditLimit;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::entity-inheritance-single-table-example[]
|
||||
|
||||
public BigDecimal getCreditLimit() {
|
||||
return creditLimit;
|
||||
}
|
||||
|
@ -137,6 +151,7 @@ public class SingleTableTest extends BaseEntityManagerFunctionalTestCase {
|
|||
public void setCreditLimit(BigDecimal creditLimit) {
|
||||
this.creditLimit = creditLimit;
|
||||
}
|
||||
//tag::entity-inheritance-single-table-example[]
|
||||
}
|
||||
//end::entity-inheritance-single-table-example[]
|
||||
}
|
||||
|
|
|
@ -76,6 +76,10 @@ public class TablePerClassTest extends BaseEntityManagerFunctionalTestCase {
|
|||
|
||||
private BigDecimal interestRate;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::entity-inheritance-table-per-class-example[]
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -107,6 +111,7 @@ public class TablePerClassTest extends BaseEntityManagerFunctionalTestCase {
|
|||
public void setInterestRate(BigDecimal interestRate) {
|
||||
this.interestRate = interestRate;
|
||||
}
|
||||
//tag::entity-inheritance-table-per-class-example[]
|
||||
}
|
||||
|
||||
@Entity(name = "DebitAccount")
|
||||
|
@ -114,6 +119,10 @@ public class TablePerClassTest extends BaseEntityManagerFunctionalTestCase {
|
|||
|
||||
private BigDecimal overdraftFee;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::entity-inheritance-table-per-class-example[]
|
||||
|
||||
public BigDecimal getOverdraftFee() {
|
||||
return overdraftFee;
|
||||
}
|
||||
|
@ -121,6 +130,7 @@ public class TablePerClassTest extends BaseEntityManagerFunctionalTestCase {
|
|||
public void setOverdraftFee(BigDecimal overdraftFee) {
|
||||
this.overdraftFee = overdraftFee;
|
||||
}
|
||||
//tag::entity-inheritance-table-per-class-example[]
|
||||
}
|
||||
|
||||
@Entity(name = "CreditAccount")
|
||||
|
@ -128,6 +138,10 @@ public class TablePerClassTest extends BaseEntityManagerFunctionalTestCase {
|
|||
|
||||
private BigDecimal creditLimit;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::entity-inheritance-table-per-class-example[]
|
||||
|
||||
public BigDecimal getCreditLimit() {
|
||||
return creditLimit;
|
||||
}
|
||||
|
@ -135,6 +149,7 @@ public class TablePerClassTest extends BaseEntityManagerFunctionalTestCase {
|
|||
public void setCreditLimit(BigDecimal creditLimit) {
|
||||
this.creditLimit = creditLimit;
|
||||
}
|
||||
//tag::entity-inheritance-table-per-class-example[]
|
||||
}
|
||||
//end::entity-inheritance-table-per-class-example[]
|
||||
}
|
||||
|
|
|
@ -66,6 +66,9 @@ public class BitSetTypeDefTest extends BaseCoreFunctionalTestCase {
|
|||
|
||||
private BitSet bitSet;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
//end::basic-custom-type-BitSetTypeDef-mapping-example[]
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -81,6 +84,7 @@ public class BitSetTypeDefTest extends BaseCoreFunctionalTestCase {
|
|||
public void setBitSet(BitSet bitSet) {
|
||||
this.bitSet = bitSet;
|
||||
}
|
||||
//tag::basic-custom-type-BitSetTypeDef-mapping-example[]
|
||||
}
|
||||
//end::basic-custom-type-BitSetTypeDef-mapping-example[]
|
||||
}
|
||||
|
|
|
@ -76,6 +76,9 @@ public class BitSetTypeTest extends BaseCoreFunctionalTestCase {
|
|||
return id;
|
||||
}
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
//end::basic-custom-type-BitSetType-mapping-example[]
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
@ -87,6 +90,7 @@ public class BitSetTypeTest extends BaseCoreFunctionalTestCase {
|
|||
public void setBitSet(BitSet bitSet) {
|
||||
this.bitSet = bitSet;
|
||||
}
|
||||
//tag::basic-custom-type-BitSetType-mapping-example[]
|
||||
}
|
||||
//end::basic-custom-type-BitSetType-mapping-example[]
|
||||
}
|
||||
|
|
|
@ -119,6 +119,8 @@ public class BitSetUserTypeTest extends BaseCoreFunctionalTestCase {
|
|||
|
||||
@Type( type = "bitset" )
|
||||
private BitSet bitSet;
|
||||
|
||||
//Constructors, getters and setters are omitted for brevity
|
||||
//end::basic-custom-type-BitSetUserType-mapping-example[]
|
||||
public Product() {
|
||||
}
|
||||
|
@ -127,7 +129,6 @@ public class BitSetUserTypeTest extends BaseCoreFunctionalTestCase {
|
|||
this.id = id.intValue();
|
||||
this.bitSet = bitSet;
|
||||
}
|
||||
//tag::basic-custom-type-BitSetUserType-mapping-example[]
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
|
@ -144,6 +145,7 @@ public class BitSetUserTypeTest extends BaseCoreFunctionalTestCase {
|
|||
public void setBitSet(BitSet bitSet) {
|
||||
this.bitSet = bitSet;
|
||||
}
|
||||
//tag::basic-custom-type-BitSetUserType-mapping-example[]
|
||||
}
|
||||
//end::basic-custom-type-BitSetUserType-mapping-example[]
|
||||
}
|
||||
|
|
|
@ -164,8 +164,11 @@ public class JoinColumnOrFormulaTest extends BaseEntityManagerFunctionalTestCase
|
|||
this.country = country;
|
||||
}
|
||||
|
||||
//tag::mapping-JoinColumnOrFormula-example[]
|
||||
//tag::mapping-JoinColumnOrFormula-example[]
|
||||
}
|
||||
//end::mapping-JoinColumnOrFormula-example[]
|
||||
|
||||
//tag::mapping-JoinColumnOrFormula-example[]
|
||||
|
||||
@Entity(name = "Country")
|
||||
@Table(name = "countries")
|
||||
|
@ -181,6 +184,10 @@ public class JoinColumnOrFormulaTest extends BaseEntityManagerFunctionalTestCase
|
|||
@Column(name = "is_default")
|
||||
private boolean _default;
|
||||
|
||||
//Getters and setters, equals and hashCode methods omitted for brevity
|
||||
|
||||
//end::mapping-JoinColumnOrFormula-example[]
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -229,6 +236,7 @@ public class JoinColumnOrFormulaTest extends BaseEntityManagerFunctionalTestCase
|
|||
public int hashCode() {
|
||||
return Objects.hash( getId() );
|
||||
}
|
||||
//tag::mapping-JoinColumnOrFormula-example[]
|
||||
}
|
||||
//end::mapping-JoinColumnOrFormula-example[]
|
||||
}
|
||||
|
|
|
@ -143,6 +143,9 @@ public class JoinFormulaTest extends BaseEntityManagerFunctionalTestCase {
|
|||
|
||||
//tag::mapping-JoinFormula-example[]
|
||||
}
|
||||
//end::mapping-JoinFormula-example[]
|
||||
|
||||
//tag::mapping-JoinFormula-example[]
|
||||
|
||||
@Entity(name = "Country")
|
||||
@Table(name = "countries")
|
||||
|
@ -153,6 +156,10 @@ public class JoinFormulaTest extends BaseEntityManagerFunctionalTestCase {
|
|||
|
||||
private String name;
|
||||
|
||||
//Getters and setters, equals and hashCode methods omitted for brevity
|
||||
|
||||
//end::mapping-JoinFormula-example[]
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -185,6 +192,7 @@ public class JoinFormulaTest extends BaseEntityManagerFunctionalTestCase {
|
|||
public int hashCode() {
|
||||
return Objects.hash( getId() );
|
||||
}
|
||||
//tag::mapping-JoinFormula-example[]
|
||||
}
|
||||
//end::mapping-JoinFormula-example[]
|
||||
}
|
||||
|
|
|
@ -70,6 +70,10 @@ public class ParentTest extends BaseEntityManagerFunctionalTestCase {
|
|||
@Parent
|
||||
private City city;
|
||||
|
||||
//Getters and setters omitted for brevity
|
||||
|
||||
//end::mapping-Parent-example[]
|
||||
|
||||
private GPS() {
|
||||
}
|
||||
|
||||
|
@ -93,7 +97,11 @@ public class ParentTest extends BaseEntityManagerFunctionalTestCase {
|
|||
public void setCity(City city) {
|
||||
this.city = city;
|
||||
}
|
||||
//tag::mapping-Parent-example[]
|
||||
}
|
||||
//end::mapping-Parent-example[]
|
||||
|
||||
//tag::mapping-Parent-example[]
|
||||
|
||||
@Entity(name = "City")
|
||||
public static class City {
|
||||
|
|
|
@ -54,6 +54,9 @@ public class MoneyConverterTest extends BaseEntityManagerFunctionalTestCase {
|
|||
|
||||
private long cents;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
//end::basic-jpa-convert-money-converter-mapping-example[]
|
||||
|
||||
public Money(long cents) {
|
||||
this.cents = cents;
|
||||
}
|
||||
|
@ -65,23 +68,12 @@ public class MoneyConverterTest extends BaseEntityManagerFunctionalTestCase {
|
|||
public void setCents(long cents) {
|
||||
this.cents = cents;
|
||||
}
|
||||
//tag::basic-jpa-convert-money-converter-mapping-example[]
|
||||
}
|
||||
|
||||
public static class MoneyConverter
|
||||
implements AttributeConverter<Money, Long> {
|
||||
|
||||
@Override
|
||||
public Long convertToDatabaseColumn(Money attribute) {
|
||||
return attribute == null ? null : attribute.getCents();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Money convertToEntityAttribute(Long dbData) {
|
||||
return dbData == null ? null : new Money( dbData );
|
||||
}
|
||||
}
|
||||
//end::basic-jpa-convert-money-converter-mapping-example[]
|
||||
|
||||
//tag::basic-jpa-convert-money-converter-mapping-example[]
|
||||
|
||||
@Entity(name = "Account")
|
||||
public static class Account {
|
||||
|
||||
|
@ -94,8 +86,7 @@ public class MoneyConverterTest extends BaseEntityManagerFunctionalTestCase {
|
|||
private Money balance;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::basic-jpa-convert-money-converter-mapping-example[]
|
||||
//end::basic-jpa-convert-money-converter-mapping-example[]
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -121,5 +112,19 @@ public class MoneyConverterTest extends BaseEntityManagerFunctionalTestCase {
|
|||
}
|
||||
//tag::basic-jpa-convert-money-converter-mapping-example[]
|
||||
}
|
||||
|
||||
public static class MoneyConverter
|
||||
implements AttributeConverter<Money, Long> {
|
||||
|
||||
@Override
|
||||
public Long convertToDatabaseColumn(Money attribute) {
|
||||
return attribute == null ? null : attribute.getCents();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Money convertToEntityAttribute(Long dbData) {
|
||||
return dbData == null ? null : new Money( dbData );
|
||||
}
|
||||
}
|
||||
//end::basic-jpa-convert-money-converter-mapping-example[]
|
||||
}
|
||||
|
|
|
@ -141,6 +141,9 @@ public class EmbeddableImplicitOverrideTest
|
|||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
private Country country;
|
||||
|
||||
//Getters and setters, equals and hashCode methods omitted for brevity
|
||||
//end::embeddable-multiple-namingstrategy-entity-mapping[]
|
||||
|
||||
public Publisher(String name, Country country) {
|
||||
this.name = name;
|
||||
this.country = country;
|
||||
|
@ -148,9 +151,6 @@ public class EmbeddableImplicitOverrideTest
|
|||
|
||||
private Publisher() {}
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
//end::embeddable-multiple-namingstrategy-entity-mapping[]
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
|
|
@ -161,6 +161,10 @@ public class EmbeddableOverrideTest extends BaseEntityManagerFunctionalTestCase
|
|||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
private Country country;
|
||||
|
||||
//Getters and setters, equals and hashCode methods omitted for brevity
|
||||
|
||||
//end::embeddable-type-association-mapping-example[]
|
||||
|
||||
public Publisher(String name, Country country) {
|
||||
this.name = name;
|
||||
this.country = country;
|
||||
|
@ -168,9 +172,6 @@ public class EmbeddableOverrideTest extends BaseEntityManagerFunctionalTestCase
|
|||
|
||||
private Publisher() {}
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
//end::embeddable-type-association-mapping-example[]
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
|
|
@ -110,6 +110,11 @@ public class SimpleEmbeddableTest extends BaseEntityManagerFunctionalTestCase {
|
|||
@Column(name = "publisher_country")
|
||||
private String country;
|
||||
|
||||
//Getters and setters, equals and hashCode methods omitted for brevity
|
||||
|
||||
//end::embeddable-type-mapping-example[]
|
||||
|
||||
|
||||
public Publisher(String name, String country) {
|
||||
this.name = name;
|
||||
this.country = country;
|
||||
|
@ -117,9 +122,6 @@ public class SimpleEmbeddableTest extends BaseEntityManagerFunctionalTestCase {
|
|||
|
||||
private Publisher() {}
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
//end::embeddable-type-mapping-example[]
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
|
|
@ -53,6 +53,9 @@ public class CreationTimestampTest extends BaseEntityManagerFunctionalTestCase {
|
|||
@CreationTimestamp
|
||||
private Date timestamp;
|
||||
|
||||
//Constructors, getters and setters are omitted for brevity
|
||||
//end::mapping-generated-CreationTimestamp-example[]
|
||||
|
||||
public Event() {}
|
||||
|
||||
public Long getId() {
|
||||
|
@ -62,6 +65,7 @@ public class CreationTimestampTest extends BaseEntityManagerFunctionalTestCase {
|
|||
public Date getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
//tag::mapping-generated-CreationTimestamp-example[]
|
||||
}
|
||||
//end::mapping-generated-CreationTimestamp-example[]
|
||||
}
|
||||
|
|
|
@ -56,6 +56,9 @@ public class DatabaseValueGenerationTest extends BaseEntityManagerFunctionalTest
|
|||
@FunctionCreationTimestamp
|
||||
private Date timestamp;
|
||||
|
||||
//Constructors, getters and setters are omitted for brevity
|
||||
//end::mapping-database-generated-value-example[]
|
||||
|
||||
public Event() {}
|
||||
|
||||
public Long getId() {
|
||||
|
@ -65,7 +68,11 @@ public class DatabaseValueGenerationTest extends BaseEntityManagerFunctionalTest
|
|||
public Date getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
//tag::mapping-database-generated-value-example[]
|
||||
}
|
||||
//end::mapping-database-generated-value-example[]
|
||||
|
||||
//tag::mapping-database-generated-value-example[]
|
||||
|
||||
@ValueGenerationType(generatedBy = FunctionCreationValueGeneration.class)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
|
|
@ -56,6 +56,8 @@ public class InMemoryValueGenerationTest extends BaseEntityManagerFunctionalTest
|
|||
@FunctionCreationTimestamp
|
||||
private Date timestamp;
|
||||
|
||||
//Constructors, getters and setters are omitted for brevity
|
||||
//end::mapping-in-memory-generated-value-example[]
|
||||
public Event() {}
|
||||
|
||||
public Long getId() {
|
||||
|
@ -65,7 +67,11 @@ public class InMemoryValueGenerationTest extends BaseEntityManagerFunctionalTest
|
|||
public Date getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
//tag::mapping-in-memory-generated-value-example[]
|
||||
}
|
||||
//end::mapping-in-memory-generated-value-example[]
|
||||
|
||||
//tag::mapping-in-memory-generated-value-example[]
|
||||
|
||||
@ValueGenerationType(generatedBy = FunctionCreationValueGeneration.class)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
|
|
@ -88,6 +88,10 @@ public class BytecodeEnhancementTest extends BaseEntityManagerFunctionalTestCase
|
|||
@LazyGroup( "lobs" )
|
||||
private Blob image;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::BytecodeEnhancement-lazy-loading-example[]
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -119,6 +123,7 @@ public class BytecodeEnhancementTest extends BaseEntityManagerFunctionalTestCase
|
|||
public void setImage(Blob image) {
|
||||
this.image = image;
|
||||
}
|
||||
//tag::BytecodeEnhancement-lazy-loading-example[]
|
||||
}
|
||||
//end::BytecodeEnhancement-lazy-loading-example[]
|
||||
|
||||
|
@ -132,7 +137,11 @@ public class BytecodeEnhancementTest extends BaseEntityManagerFunctionalTestCase
|
|||
private String name;
|
||||
|
||||
@OneToMany(mappedBy = "author")
|
||||
private List<Book> books = new ArrayList<>( );
|
||||
private List<Book> books = new ArrayList<>();
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::BytecodeEnhancement-dirty-tracking-bidirectional-example[]
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
|
@ -153,6 +162,7 @@ public class BytecodeEnhancementTest extends BaseEntityManagerFunctionalTestCase
|
|||
public List<Book> getBooks() {
|
||||
return books;
|
||||
}
|
||||
//tag::BytecodeEnhancement-dirty-tracking-bidirectional-example[]
|
||||
}
|
||||
|
||||
@Entity(name = "Book")
|
||||
|
@ -169,6 +179,10 @@ public class BytecodeEnhancementTest extends BaseEntityManagerFunctionalTestCase
|
|||
@ManyToOne
|
||||
private Person author;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::BytecodeEnhancement-dirty-tracking-bidirectional-example[]
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -200,6 +214,7 @@ public class BytecodeEnhancementTest extends BaseEntityManagerFunctionalTestCase
|
|||
public void setIsbn(String isbn) {
|
||||
this.isbn = isbn;
|
||||
}
|
||||
//tag::BytecodeEnhancement-dirty-tracking-bidirectional-example[]
|
||||
}
|
||||
//end::BytecodeEnhancement-dirty-tracking-bidirectional-example[]
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public class CascadeOnDeleteTest extends BaseEntityManagerFunctionalTestCase {
|
|||
} );
|
||||
}
|
||||
|
||||
//tag::pc-cascade-on-delete-mapping-example[]
|
||||
//tag::pc-cascade-on-delete-mapping-Person-example[]
|
||||
@Entity(name = "Person")
|
||||
public static class Person {
|
||||
|
||||
|
@ -60,7 +60,8 @@ public class CascadeOnDeleteTest extends BaseEntityManagerFunctionalTestCase {
|
|||
private String name;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
//end::pc-cascade-on-delete-mapping-example[]
|
||||
|
||||
//end::pc-cascade-on-delete-mapping-Person-example[]
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
|
@ -77,9 +78,11 @@ public class CascadeOnDeleteTest extends BaseEntityManagerFunctionalTestCase {
|
|||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
//tag::pc-cascade-on-delete-mapping-example[]
|
||||
//tag::pc-cascade-on-delete-mapping-Person-example[]
|
||||
}
|
||||
|
||||
//end::pc-cascade-on-delete-mapping-Person-example[]
|
||||
|
||||
//tag::pc-cascade-on-delete-mapping-Phone-example[]
|
||||
@Entity(name = "Phone")
|
||||
public static class Phone {
|
||||
|
||||
|
@ -94,7 +97,8 @@ public class CascadeOnDeleteTest extends BaseEntityManagerFunctionalTestCase {
|
|||
private Person owner;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
//end::pc-cascade-on-delete-mapping-example[]
|
||||
|
||||
//end::pc-cascade-on-delete-mapping-Phone-example[]
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
|
@ -119,7 +123,7 @@ public class CascadeOnDeleteTest extends BaseEntityManagerFunctionalTestCase {
|
|||
public void setOwner(Person owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
//tag::pc-cascade-on-delete-mapping-example[]
|
||||
//tag::pc-cascade-on-delete-mapping-Phone-example[]
|
||||
}
|
||||
//end::pc-cascade-on-delete-mapping-example[]
|
||||
//end::pc-cascade-on-delete-mapping-Phone-example[]
|
||||
}
|
|
@ -418,6 +418,10 @@ public class PersistenceContextTest extends BaseEntityManagerFunctionalTestCase
|
|||
@ManyToOne
|
||||
private Person author;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::pc-find-by-natural-id-entity-example[]
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -449,6 +453,7 @@ public class PersistenceContextTest extends BaseEntityManagerFunctionalTestCase
|
|||
public void setIsbn(String isbn) {
|
||||
this.isbn = isbn;
|
||||
}
|
||||
//tag::pc-find-by-natural-id-entity-example[]
|
||||
}
|
||||
//end::pc-find-by-natural-id-entity-example[]
|
||||
}
|
||||
|
|
|
@ -22,6 +22,9 @@ public class Person {
|
|||
@OneToMany(mappedBy = "owner", cascade = CascadeType.ALL)
|
||||
private List<Phone> phones = new ArrayList<>();
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
//end::pc-cascade-domain-model-example[]
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -42,6 +45,8 @@ public class Person {
|
|||
return phones;
|
||||
}
|
||||
|
||||
//tag::pc-cascade-domain-model-example[]
|
||||
|
||||
public void addPhone(Phone phone) {
|
||||
this.phones.add( phone );
|
||||
phone.setOwner( this );
|
||||
|
|
|
@ -22,6 +22,9 @@ public class Phone {
|
|||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
private Person owner;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
//end::pc-cascade-domain-model-example[]
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -45,5 +48,6 @@ public class Phone {
|
|||
public void setOwner(Person owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
//tag::pc-cascade-domain-model-example[]
|
||||
}
|
||||
//end::pc-cascade-domain-model-example[]
|
|
@ -31,6 +31,7 @@ public class Author {
|
|||
public Set<Book> books = new HashSet<>();
|
||||
|
||||
//Getters and setters omitted for brevity
|
||||
|
||||
//end::entity-persister-mapping[]
|
||||
|
||||
public Integer getId() {
|
||||
|
|
|
@ -91,6 +91,10 @@ public class SchemaGenerationTest extends BaseEntityManagerFunctionalTestCase {
|
|||
@LazyGroup( "lobs" )
|
||||
private Blob image;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::schema-generation-domain-model-example[]
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -122,6 +126,7 @@ public class SchemaGenerationTest extends BaseEntityManagerFunctionalTestCase {
|
|||
public void setImage(Blob image) {
|
||||
this.image = image;
|
||||
}
|
||||
//tag::schema-generation-domain-model-example[]
|
||||
}
|
||||
|
||||
@Entity(name = "Person")
|
||||
|
@ -133,7 +138,11 @@ public class SchemaGenerationTest extends BaseEntityManagerFunctionalTestCase {
|
|||
private String name;
|
||||
|
||||
@OneToMany(mappedBy = "author")
|
||||
private List<Book> books = new ArrayList<>( );
|
||||
private List<Book> books = new ArrayList<>();
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::schema-generation-domain-model-example[]
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
|
@ -154,6 +163,7 @@ public class SchemaGenerationTest extends BaseEntityManagerFunctionalTestCase {
|
|||
public List<Book> getBooks() {
|
||||
return books;
|
||||
}
|
||||
//tag::schema-generation-domain-model-example[]
|
||||
}
|
||||
|
||||
@Entity(name = "Book")
|
||||
|
@ -170,6 +180,10 @@ public class SchemaGenerationTest extends BaseEntityManagerFunctionalTestCase {
|
|||
@ManyToOne
|
||||
private Person author;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::schema-generation-domain-model-example[]
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -201,6 +215,7 @@ public class SchemaGenerationTest extends BaseEntityManagerFunctionalTestCase {
|
|||
public void setIsbn(String isbn) {
|
||||
this.isbn = isbn;
|
||||
}
|
||||
//tag::schema-generation-domain-model-example[]
|
||||
}
|
||||
//end::schema-generation-domain-model-example[]
|
||||
}
|
||||
|
|
|
@ -21,6 +21,10 @@ public class Captain {
|
|||
@EmbeddedId
|
||||
private Identity id;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::sql-composite-key-entity-associations_named-query-example[]
|
||||
|
||||
public Identity getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -28,5 +32,6 @@ public class Captain {
|
|||
public void setId(Identity id) {
|
||||
this.id = id;
|
||||
}
|
||||
//tag::sql-composite-key-entity-associations_named-query-example[]
|
||||
}
|
||||
//end::sql-composite-key-entity-associations_named-query-example[]
|
|
@ -43,122 +43,127 @@ import static org.junit.Assert.assertNull;
|
|||
@RequiresDialect(PostgreSQL82Dialect.class)
|
||||
public class CustomSQLSecondaryTableTest extends BaseEntityManagerFunctionalTestCase {
|
||||
|
||||
@Override
|
||||
protected Class<?>[] getAnnotatedClasses() {
|
||||
return new Class<?>[] {
|
||||
Person.class
|
||||
};
|
||||
}
|
||||
@Override
|
||||
protected Class<?>[] getAnnotatedClasses() {
|
||||
return new Class<?>[] {
|
||||
Person.class
|
||||
};
|
||||
}
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
Session session = entityManager.unwrap( Session.class );
|
||||
session.doWork( connection -> {
|
||||
try(Statement statement = connection.createStatement(); ) {
|
||||
statement.executeUpdate( "ALTER TABLE person ADD COLUMN valid boolean" );
|
||||
statement.executeUpdate( "ALTER TABLE person_details ADD COLUMN valid boolean" );
|
||||
}
|
||||
} );
|
||||
});
|
||||
}
|
||||
@Before
|
||||
public void init() {
|
||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
Session session = entityManager.unwrap( Session.class );
|
||||
session.doWork( connection -> {
|
||||
try(Statement statement = connection.createStatement(); ) {
|
||||
statement.executeUpdate( "ALTER TABLE person ADD COLUMN valid boolean" );
|
||||
statement.executeUpdate( "ALTER TABLE person_details ADD COLUMN valid boolean" );
|
||||
}
|
||||
} );
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_sql_custom_crud() {
|
||||
@Test
|
||||
public void test_sql_custom_crud() {
|
||||
|
||||
Person _person = doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
Person person = new Person();
|
||||
person.setName( "John Doe" );
|
||||
entityManager.persist( person );
|
||||
person.setImage( new byte[] {1, 2, 3} );
|
||||
return person;
|
||||
} );
|
||||
Person _person = doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
Person person = new Person();
|
||||
person.setName( "John Doe" );
|
||||
entityManager.persist( person );
|
||||
person.setImage( new byte[] {1, 2, 3} );
|
||||
return person;
|
||||
} );
|
||||
|
||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
Long postId = _person.getId();
|
||||
Person person = entityManager.find( Person.class, postId );
|
||||
assertArrayEquals(new byte[] {1, 2, 3}, person.getImage());
|
||||
entityManager.remove( person );
|
||||
} );
|
||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
Long postId = _person.getId();
|
||||
Person person = entityManager.find( Person.class, postId );
|
||||
assertArrayEquals(new byte[] {1, 2, 3}, person.getImage());
|
||||
entityManager.remove( person );
|
||||
} );
|
||||
|
||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
Long postId = _person.getId();
|
||||
Person person = entityManager.find( Person.class, postId );
|
||||
assertNull(person);
|
||||
} );
|
||||
}
|
||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
Long postId = _person.getId();
|
||||
Person person = entityManager.find( Person.class, postId );
|
||||
assertNull(person);
|
||||
} );
|
||||
}
|
||||
|
||||
|
||||
//tag::sql-custom-crud-secondary-table-example[]
|
||||
@Entity(name = "Person")
|
||||
@Table(name = "person")
|
||||
@SQLInsert(
|
||||
sql = "INSERT INTO person (name, id, valid) VALUES (?, ?, true) "
|
||||
)
|
||||
@SQLDelete(
|
||||
sql = "UPDATE person SET valid = false WHERE id = ? "
|
||||
)
|
||||
@SecondaryTable(name = "person_details",
|
||||
pkJoinColumns = @PrimaryKeyJoinColumn(name = "person_id"))
|
||||
@org.hibernate.annotations.Table(
|
||||
appliesTo = "person_details",
|
||||
sqlInsert = @SQLInsert(
|
||||
sql = "INSERT INTO person_details (image, person_id, valid) VALUES (?, ?, true) ",
|
||||
check = ResultCheckStyle.COUNT
|
||||
),
|
||||
sqlDelete = @SQLDelete(
|
||||
sql = "UPDATE person_details SET valid = false WHERE person_id = ? "
|
||||
)
|
||||
)
|
||||
@Loader(namedQuery = "find_valid_person")
|
||||
@NamedNativeQueries({
|
||||
@NamedNativeQuery(
|
||||
name = "find_valid_person",
|
||||
query = "select " +
|
||||
" p.id, " +
|
||||
" p.name, " +
|
||||
" pd.image " +
|
||||
"from person p " +
|
||||
"left outer join person_details pd on p.id = pd.person_id " +
|
||||
"where p.id = ? and p.valid = true and pd.valid = true",
|
||||
resultClass = Person.class
|
||||
)
|
||||
})
|
||||
public static class Person {
|
||||
//tag::sql-custom-crud-secondary-table-example[]
|
||||
@Entity(name = "Person")
|
||||
@Table(name = "person")
|
||||
@SQLInsert(
|
||||
sql = "INSERT INTO person (name, id, valid) VALUES (?, ?, true) "
|
||||
)
|
||||
@SQLDelete(
|
||||
sql = "UPDATE person SET valid = false WHERE id = ? "
|
||||
)
|
||||
@SecondaryTable(name = "person_details",
|
||||
pkJoinColumns = @PrimaryKeyJoinColumn(name = "person_id"))
|
||||
@org.hibernate.annotations.Table(
|
||||
appliesTo = "person_details",
|
||||
sqlInsert = @SQLInsert(
|
||||
sql = "INSERT INTO person_details (image, person_id, valid) VALUES (?, ?, true) ",
|
||||
check = ResultCheckStyle.COUNT
|
||||
),
|
||||
sqlDelete = @SQLDelete(
|
||||
sql = "UPDATE person_details SET valid = false WHERE person_id = ? "
|
||||
)
|
||||
)
|
||||
@Loader(namedQuery = "find_valid_person")
|
||||
@NamedNativeQueries({
|
||||
@NamedNativeQuery(
|
||||
name = "find_valid_person",
|
||||
query = "SELECT " +
|
||||
" p.id, " +
|
||||
" p.name, " +
|
||||
" pd.image " +
|
||||
"FROM person p " +
|
||||
"LEFT OUTER JOIN person_details pd ON p.id = pd.person_id " +
|
||||
"WHERE p.id = ? AND p.valid = true AND pd.valid = true",
|
||||
resultClass = Person.class
|
||||
)
|
||||
})
|
||||
public static class Person {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
private String name;
|
||||
|
||||
@Column(name = "image", table = "person_details")
|
||||
private byte[] image;
|
||||
@Column(name = "image", table = "person_details")
|
||||
private byte[] image;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
//end::sql-custom-crud-secondary-table-example[]
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public byte[] getImage() {
|
||||
return image;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setImage(byte[] image) {
|
||||
this.image = image;
|
||||
}
|
||||
}
|
||||
//end::sql-custom-crud-secondary-table-example[]
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public byte[] getImage() {
|
||||
return image;
|
||||
}
|
||||
|
||||
public void setImage(byte[] image) {
|
||||
this.image = image;
|
||||
}
|
||||
//tag::sql-custom-crud-secondary-table-example[]
|
||||
}
|
||||
//end::sql-custom-crud-secondary-table-example[]
|
||||
|
||||
}
|
||||
|
|
|
@ -99,7 +99,6 @@ public class CustomSQLTest extends BaseEntityManagerFunctionalTestCase {
|
|||
} );
|
||||
}
|
||||
|
||||
|
||||
//tag::sql-custom-crud-example[]
|
||||
@Entity(name = "Person")
|
||||
@SQLInsert(
|
||||
|
@ -107,9 +106,11 @@ public class CustomSQLTest extends BaseEntityManagerFunctionalTestCase {
|
|||
check = ResultCheckStyle.COUNT
|
||||
)
|
||||
@SQLUpdate(
|
||||
sql = "UPDATE person SET name = ? where id = ? ")
|
||||
sql = "UPDATE person SET name = ? where id = ? "
|
||||
)
|
||||
@SQLDelete(
|
||||
sql = "UPDATE person SET valid = false WHERE id = ? ")
|
||||
sql = "UPDATE person SET valid = false WHERE id = ? "
|
||||
)
|
||||
@Loader(namedQuery = "find_valid_person")
|
||||
@NamedNativeQueries({
|
||||
@NamedNativeQuery(
|
||||
|
@ -136,6 +137,10 @@ public class CustomSQLTest extends BaseEntityManagerFunctionalTestCase {
|
|||
@Where( clause = "valid = true" )
|
||||
private List<String> phones = new ArrayList<>();
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::sql-custom-crud-example[]
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -155,7 +160,7 @@ public class CustomSQLTest extends BaseEntityManagerFunctionalTestCase {
|
|||
public List<String> getPhones() {
|
||||
return phones;
|
||||
}
|
||||
//tag::sql-custom-crud-example[]
|
||||
}
|
||||
//end::sql-custom-crud-example[]
|
||||
|
||||
}
|
||||
|
|
|
@ -21,6 +21,10 @@ public class Dimensions {
|
|||
|
||||
private int width;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::sql-composite-key-entity-associations_named-query-example[]
|
||||
|
||||
public int getLength() {
|
||||
return length;
|
||||
}
|
||||
|
@ -36,5 +40,6 @@ public class Dimensions {
|
|||
public void setWidth(int width) {
|
||||
this.width = width;
|
||||
}
|
||||
//tag::sql-composite-key-entity-associations_named-query-example[]
|
||||
}
|
||||
//end::sql-composite-key-entity-associations_named-query-example[]
|
||||
|
|
|
@ -22,6 +22,10 @@ public class Identity implements Serializable {
|
|||
|
||||
private String lastname;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::sql-composite-key-entity-associations_named-query-example[]
|
||||
|
||||
public String getFirstname() {
|
||||
return firstname;
|
||||
}
|
||||
|
@ -38,6 +42,7 @@ public class Identity implements Serializable {
|
|||
this.lastname = lastname;
|
||||
}
|
||||
|
||||
//tag::sql-composite-key-entity-associations_named-query-example[]
|
||||
public boolean equals(Object o) {
|
||||
if ( this == o ) return true;
|
||||
if ( o == null || getClass() != o.getClass() ) return false;
|
||||
|
|
|
@ -16,6 +16,8 @@ public class PersonSummaryDTO {
|
|||
|
||||
private String name;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
public Number getId() {
|
||||
return id;
|
||||
}
|
||||
|
|
|
@ -495,10 +495,10 @@ public class SQLTest extends BaseEntityManagerFunctionalTestCase {
|
|||
Session session = entityManager.unwrap( Session.class );
|
||||
//tag::sql-hibernate-multi-entity-query-example[]
|
||||
List<Object> entities = session.createNativeQuery(
|
||||
"SELECT * " +
|
||||
"FROM Person pr, Partner pt " +
|
||||
"WHERE pr.name = pt.name" )
|
||||
.list();
|
||||
"SELECT * " +
|
||||
"FROM Person pr, Partner pt " +
|
||||
"WHERE pr.name = pt.name" )
|
||||
.list();
|
||||
//end::sql-hibernate-multi-entity-query-example[]
|
||||
assertEquals( 2, entities.size() );
|
||||
} );
|
||||
|
|
|
@ -81,6 +81,10 @@ public class SpaceShip {
|
|||
|
||||
private Dimensions dimensions;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::sql-composite-key-entity-associations_named-query-example[]
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
@ -120,5 +124,6 @@ public class SpaceShip {
|
|||
public void setDimensions(Dimensions dimensions) {
|
||||
this.dimensions = dimensions;
|
||||
}
|
||||
//tag::sql-composite-key-entity-associations_named-query-example[]
|
||||
}
|
||||
//end::sql-composite-key-entity-associations_named-query-example[]
|
||||
|
|
|
@ -127,6 +127,10 @@ public abstract class AbstractBulkCompositeIdTest extends BaseCoreFunctionalTest
|
|||
|
||||
private boolean employed;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::batch-bulk-hql-temp-table-base-class-example[]
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -176,6 +180,7 @@ public abstract class AbstractBulkCompositeIdTest extends BaseCoreFunctionalTest
|
|||
public int hashCode() {
|
||||
return Objects.hash( getId(), getCompanyName() );
|
||||
}
|
||||
//tag::batch-bulk-hql-temp-table-base-class-example[]
|
||||
}
|
||||
//end::batch-bulk-hql-temp-table-base-class-example[]
|
||||
|
||||
|
@ -189,6 +194,10 @@ public abstract class AbstractBulkCompositeIdTest extends BaseCoreFunctionalTest
|
|||
|
||||
private boolean fellow;
|
||||
|
||||
//Getters and setters are omitted for brevity
|
||||
|
||||
//end::batch-bulk-hql-temp-table-sub-classes-example[]
|
||||
|
||||
public boolean isFellow() {
|
||||
return fellow;
|
||||
}
|
||||
|
@ -196,6 +205,7 @@ public abstract class AbstractBulkCompositeIdTest extends BaseCoreFunctionalTest
|
|||
public void setFellow(boolean fellow) {
|
||||
this.fellow = fellow;
|
||||
}
|
||||
//tag::batch-bulk-hql-temp-table-sub-classes-example[]
|
||||
}
|
||||
//end::batch-bulk-hql-temp-table-sub-classes-example[]
|
||||
}
|
Loading…
Reference in New Issue