Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: support for transient fields?

  1. #1
    Join Date
    Feb 2012
    Posts
    4

    Default support for transient fields?

    Hello,

    do you plan on including support for transient fields in the next version?

    Regards

  2. #2
    Join Date
    Jan 2009
    Location
    Huntington Beach, CA
    Posts
    718

    Default

    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

  3. #3
    Join Date
    Feb 2012
    Posts
    4

    Default

    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...

  4. #4
    Join Date
    Jan 2009
    Location
    Huntington Beach, CA
    Posts
    718

    Default

    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

  5. #5
    Join Date
    Feb 2012
    Posts
    4

    Default

    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.

  6. #6
    Join Date
    Jan 2011
    Location
    Dresden, Germany
    Posts
    525

    Default

    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

  7. #7
    Join Date
    Jan 2011
    Location
    Dresden, Germany
    Posts
    525

    Default

    Btw. isReallyTransient is used here:


    TransientFieldAccessorFactory
    public boolean accept(final Neo4jPersistentProperty property) {
    return property.isReallyTransient();
    }

  8. #8
    Join Date
    Feb 2012
    Posts
    4

    Default

    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)?

  9. #9
    Join Date
    Jan 2011
    Location
    Dresden, Germany
    Posts
    525

    Default

    They should be supported just fine, which exception / error do you encounter?

    Michael

  10. #10
    Join Date
    Jan 2009
    Location
    Huntington Beach, CA
    Posts
    718

    Default

    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
  •