-
Feb 5th, 2012, 04:41 PM
#1
support for transient fields?
Hello,
do you plan on including support for transient fields in the next version?
Regards
-
Feb 5th, 2012, 04:52 PM
#2
Just commenting, but I thought it already does. If you don't want a property to be mapped make it transient.
From the docs
"Transient fields are not persisted."
Mark
-
Feb 5th, 2012, 07:04 PM
#3
I though that as well, however when I marked a property to be transient I got this exception:
org.springframework.core.convert.ConversionFailedE xception: Unable to convert value "null" from type 'null' to type 'double';
Backtracing the stack trace I got to the Neo4JPersistentPropertyImpl.java where the isTransient() method returns always false:
https://github.com/SpringSource/spri...pertyImpl.java (line 306).
And there is the isReallyTransient() method that seems to do the job, but is used nowhere...
-
Feb 6th, 2012, 11:33 AM
#4
Hmm, there is a comment in the isReallyTransient about it being deprecated, and I see the return false in isTransient. Even though isReallyTransient is not used, I noticed the code also would look for java.perisitence.Transient annotation. Can you try putting that annotation on that property and just see what happens. I doubt it will work, but you can always quickly try.
Mark
-
Feb 6th, 2012, 08:02 PM
#5
Hi Mark,
thanks for the reply. I gave both the java.persistence.Transient and the org.springframework.data.annotation.Transient a go to no avail. By the way the base class (AbstractPersistentProperty) has a (seemingly) working implementation for the isTransient() method and I dunno why it was overwritten... So I forked the repo, fixed it and send a pull request... I cant see a valid reason why the method always returns false (when every tutorial out there claims that transient fields are not persisted), I hope I didnt overlook something.
-
Feb 7th, 2012, 06:55 AM
#6
Hey,
the problem is that the isTransient in AbstractPersistentProperty just excludes them from the properties, sometimes (e.g. in Cross-Store mode we still need to access those fields as they might have been made transient for JPA to ignore them.)
Will look into that anyway, could you please raise a JIRA issue (http://spring.neo4j.org/issues) to track it (and relate to this thread).
Thanks a lot
Michael
-
Feb 7th, 2012, 06:56 AM
#7
Btw. isReallyTransient is used here:
TransientFieldAccessorFactory
public boolean accept(final Neo4jPersistentProperty property) {
return property.isReallyTransient();
}
-
Feb 9th, 2012, 05:25 AM
#8
Okay, I understand the potential cross-store issue, but why does the documentation state that non-persistable fields are supported when in fact they arent (see the exception below)?
-
Feb 9th, 2012, 06:11 AM
#9
They should be supported just fine, which exception / error do you encounter?
Michael
-
Feb 9th, 2012, 11:45 AM
#10
Michael, he posted it earlier in the thread. He is getting a ConversionFailedException on that property he has as transient. So while it looks like the database doesn't store the data for that field, when you retrieve data and then go to populate the object, it is still trying to set the transient value to null. And since that property is a primitive type double, whammo! Can't assign null to a primitive.
s7orm, you could change that property to Double instead of double, just to get rid of the exception.
Then to check if transient is being supported in your case by setting a value to that property, saving it in the database, then retrieving it and seeing if that property is populated or set to null.
Mark
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules