Author: simoneg
Date: Wed May 18 23:28:51 2011
New Revision: 1124463
URL: http://svn.apache.org/viewvc?rev=1124463&view=rev
Log:
Fix to persist properties set in the constructor
Modified:
labs/magma/trunk/database-mongodb/src/main/java/org/apache/magma/database/mongo/MongoEntityDoc.aj
Modified:
labs/magma/trunk/database-mongodb/src/main/java/org/apache/magma/database/mongo/MongoEntityDoc.aj
URL:
http://svn.apache.org/viewvc/labs/magma/trunk/database-mongodb/src/main/java/org/apache/magma/database/mongo/MongoEntityDoc.aj?rev=1124463&r1=1124462&r2=1124463&view=diff
==============================================================================
---
labs/magma/trunk/database-mongodb/src/main/java/org/apache/magma/database/mongo/MongoEntityDoc.aj
(original)
+++
labs/magma/trunk/database-mongodb/src/main/java/org/apache/magma/database/mongo/MongoEntityDoc.aj
Wed May 18 23:28:51 2011
@@ -96,6 +96,7 @@ public aspect MongoEntityDoc {
void MongoEntity.prepareForDb(Transaction t) {
this.myTransaction = t;
+ this.checkGetBson();
if (this.entityDocNeedsInit) {
BeanData bd = this.beanData();
this.entityDoc.put("_jcl",
getMyTransaction().getMeta().convertToName(this.getClass()));
@@ -111,7 +112,20 @@ public aspect MongoEntityDoc {
((WithDefaultVersion)this).setVersion(1);
}
}
- }
+
+ // It's the first time we are persisting this entity,
look for values getters
+ BeanHandler bh = this.handler();
+ Set<String> pinames = bd.getPropertyNames();
+ for (String piname : pinames) {
+ PropertyInfo prop = bd.getProperty(piname);
+ if (!prop.isReadable()) continue;
+ if (prop.isJpaId() || prop.isJpaVersion() ||
prop.isJpaTransient()) continue;
+ boolean read = prop.isBasicType() ||
(prop.isMongoPersisted() && !prop.isMap() && !prop.isCollection());
+ if (read) {
+ bh.getValue(piname);
+ }
+ }
+ }
}
Transaction MongoEntity.getMyTransaction() {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]