Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

20
  • @AndreiI Please, can you elaborate ? I don't get it. Which is the old column ? Table was ID - DESCRIPTION, entity was Id - description, now I added a non-id, non-pk field to both the table and the entity, and need to assign it a value only sometimes. Commented Mar 21, 2014 at 16:24
  • Add @JoinColumn(name="INCR_FIELD") to your private FooSequence newField;, and add the FooSequence class to your persistence.xml (if needed). Afterwards, in order to get the value of NEW_FIELD use getFooSequence().getId() Commented Mar 21, 2014 at 16:33
  • No heck, same error (I added @JoinColumn(name="new_field") to private FooSequence newField; , that was the only change I made). Please, post it as an answer with some more details, I'll assign the bounty as soon as it will work, no matter the ending period, and I'll upvote every helping answer immediately. Commented Mar 21, 2014 at 16:56
  • please try using a different column than new_field (to be sure it is not caused by that column), that's why I used a new INCR_FIELD column. Commented Mar 21, 2014 at 16:58
  • 1
    @AndreaLigios exactly: it works with two tables, each with an ID field, but I doubt that is a problem for you. In order to take get the NEW_FIELD in your code, you should call getFooSequence().getId() (as I mentioned in one of my comments above). Commented Mar 27, 2014 at 11:26