Author: epbernard
Date: 2009-07-10 12:25:46 -0400 (Fri, 10 Jul 2009)
New Revision: 17071
Added:
jpamodelgen/trunk/generator/src/test/java/model/Country.java
jpamodelgen/trunk/generator/src/test/java/model/Inhabitant.java
jpamodelgen/trunk/generator/src/test/java/model/Pet.java
Modified:
jpamodelgen/trunk/generator/src/test/java/model/Address.java
jpamodelgen/trunk/generator/src/test/java/test/AccessTypeTest.java
Log:
AccessType: test for embeddable rules
Modified: jpamodelgen/trunk/generator/src/test/java/model/Address.java
===================================================================
--- jpamodelgen/trunk/generator/src/test/java/model/Address.java 2009-07-10 16:23:22 UTC
(rev 17070)
+++ jpamodelgen/trunk/generator/src/test/java/model/Address.java 2009-07-10 16:25:46 UTC
(rev 17071)
@@ -1,15 +1,22 @@
package model;
+import java.util.Set;
import javax.persistence.Embeddable;
+import javax.persistence.Access;
+import javax.persistence.AccessType;
+import javax.persistence.ElementCollection;
+import javax.persistence.CollectionTable;
/**
* @author Emmanuel Bernard
*/
@Embeddable
+(a)Access(javax.persistence.AccessType.PROPERTY)
public class Address {
private String street1;
private String city;
- private String country;
+ private Country country;
+ private Set<Inhabitant> inhabitants;
public String getStreet1() {
return street1;
@@ -27,11 +34,21 @@
this.city = city;
}
- public String getCountry() {
+ public Country getCountry() {
return country;
}
- public void setCountry(String country) {
+ public void setCountry(Country country) {
this.country = country;
}
+
+ @ElementCollection
+ @CollectionTable(name = "Add_Inh")
+ public Set<Inhabitant> getInhabitants() {
+ return inhabitants;
+ }
+
+ public void setInhabitants(Set<Inhabitant> inhabitants) {
+ this.inhabitants = inhabitants;
+ }
}
Added: jpamodelgen/trunk/generator/src/test/java/model/Country.java
===================================================================
--- jpamodelgen/trunk/generator/src/test/java/model/Country.java
(rev 0)
+++ jpamodelgen/trunk/generator/src/test/java/model/Country.java 2009-07-10 16:25:46 UTC
(rev 17071)
@@ -0,0 +1,29 @@
+package model;
+
+import javax.persistence.Embeddable;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Embeddable
+public class Country {
+ String name;
+ String iso2Code;
+ String nonPersistent;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getIso2Code() {
+ return iso2Code;
+ }
+
+ public void setIso2Code(String iso2Code) {
+ this.iso2Code = iso2Code;
+ }
+}
Added: jpamodelgen/trunk/generator/src/test/java/model/Inhabitant.java
===================================================================
--- jpamodelgen/trunk/generator/src/test/java/model/Inhabitant.java
(rev 0)
+++ jpamodelgen/trunk/generator/src/test/java/model/Inhabitant.java 2009-07-10 16:25:46
UTC (rev 17071)
@@ -0,0 +1,26 @@
+package model;
+
+import java.util.Set;
+import javax.persistence.Embeddable;
+import javax.persistence.Access;
+import javax.persistence.AccessType;
+import javax.persistence.ElementCollection;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Embeddable
+(a)Access(javax.persistence.AccessType.FIELD)
+public class Inhabitant {
+ private String name;
+ @ElementCollection
+ private Set<Pet> pets;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Added: jpamodelgen/trunk/generator/src/test/java/model/Pet.java
===================================================================
--- jpamodelgen/trunk/generator/src/test/java/model/Pet.java (rev
0)
+++ jpamodelgen/trunk/generator/src/test/java/model/Pet.java 2009-07-10 16:25:46 UTC (rev
17071)
@@ -0,0 +1,23 @@
+package model;
+
+import javax.persistence.Embeddable;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Embeddable
+public class Pet {
+ String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getNonPersistent() {
+ return null;
+ }
+}
Modified: jpamodelgen/trunk/generator/src/test/java/test/AccessTypeTest.java
===================================================================
--- jpamodelgen/trunk/generator/src/test/java/test/AccessTypeTest.java 2009-07-10 16:23:22
UTC (rev 17070)
+++ jpamodelgen/trunk/generator/src/test/java/test/AccessTypeTest.java 2009-07-10 16:25:46
UTC (rev 17071)
@@ -31,10 +31,16 @@
@Test
public void testDefaultAccessTypeForEmbeddable() throws Exception{
- absenceOfField( "model.Detail_", "nonPersistent " );
+ absenceOfField( "model.Detail_", "nonPersistent" );
}
@Test
+ public void testInheritedAccessTypeForEmbeddable() throws Exception{
+ absenceOfField( "model.Country_", "nonPersistent" );
+ absenceOfField( "model.Pet_", "nonPersistent", "Colleciton of
membeddable not taken care of" );
+ }
+
+ @Test
public void testDefaultAccessTypeForMappedSuperclass() throws Exception{
absenceOfField( "model.Detail_", "volume" );
}
Show replies by date