diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2013-08-11 10:52:01 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2013-08-11 10:52:01 +0200 |
commit | 238ee120f2220e3359722416df07853baf926a96 (patch) | |
tree | c9c6eb17f649ae88d789057457658efed8540f6c | |
parent | 01557b4626d184f58c492c3d4c1fc74cb9a29a1e (diff) | |
download | container-playground-238ee120f2220e3359722416df07853baf926a96.tar.gz container-playground-238ee120f2220e3359722416df07853baf926a96.tar.bz2 container-playground-238ee120f2220e3359722416df07853baf926a96.tar.xz container-playground-238ee120f2220e3359722416df07853baf926a96.zip |
o Making insertInto actually insert references.
-rw-r--r-- | container-compiler-plugin/src/main/java/io/trygvis/persistence/generators/DaoUtilsGenerator.java | 6 | ||||
-rw-r--r-- | myapp/src/main/java/io/trygvis/container/myapp/AddressBookDirect.java | 8 |
2 files changed, 10 insertions, 4 deletions
diff --git a/container-compiler-plugin/src/main/java/io/trygvis/persistence/generators/DaoUtilsGenerator.java b/container-compiler-plugin/src/main/java/io/trygvis/persistence/generators/DaoUtilsGenerator.java index 51b3879..e4f69b5 100644 --- a/container-compiler-plugin/src/main/java/io/trygvis/persistence/generators/DaoUtilsGenerator.java +++ b/container-compiler-plugin/src/main/java/io/trygvis/persistence/generators/DaoUtilsGenerator.java @@ -87,9 +87,9 @@ public class DaoUtilsGenerator { EntityMirror referenced = unit.get(field.type); FieldMirror idField = referenced.getIdField(); typeHandler = generatorConfiguration.typeHandler(idField.type); - accessor = field.referenceAccessor(o, idField); - setter = " stmt." + typeHandler.setter(i, accessor) + ";"; - accessor = "null"; + accessor = o.name + "." + field.javaName; + String idAccessor = field.referenceAccessor(o, idField); + setter = " stmt." + typeHandler.setter(i, idAccessor) + ";"; } if (field.notNull) { diff --git a/myapp/src/main/java/io/trygvis/container/myapp/AddressBookDirect.java b/myapp/src/main/java/io/trygvis/container/myapp/AddressBookDirect.java index b272649..7cb6b54 100644 --- a/myapp/src/main/java/io/trygvis/container/myapp/AddressBookDirect.java +++ b/myapp/src/main/java/io/trygvis/container/myapp/AddressBookDirect.java @@ -208,7 +208,6 @@ public class AddressBookDirect { } } - Company company = null; Contact o = new Contact(name, g); o.company = session.company.selectById(1l); session.contact.insert(o); @@ -225,6 +224,13 @@ public class AddressBookDirect { System.out.println("Id: " + contact.getId()); System.out.println("Name: " + contact.name); System.out.println("Gender: " + contact.gender); + if (contact.company != null) { + System.out.println("Company:"); + System.out.println(" id: " + contact.company.getId()); + System.out.println(" name: " + contact.company.name); + } else { + System.out.println("Company: <none>"); + } } System.out.println(); } |