Sep 2nd, 2010, 01:27 PM
Want to add member to @Entity class that is not bound to column
Probably like many here, I have been using my @Entity class objects as form backing objects as well as for database access.
Now I want to add a member to an @Entity class that represents a checkbox in the form. From what I have observed so far, Spring 3 MVC will attempt to map every member of an @Entity class to a database column inside the database table that the class represents. I do not want the new class member (that represents the checkbox) to be mapped to a column - it's just a flag for business logic.
How I do I accomplish this without wrapping the entire @Entity class in a new class (for a form backing object) that has one more member (the boolean)?
Sep 2nd, 2010, 02:18 PM
I had this same problem. I think you should look at using the @Transient annotation. It allows you to have a field in a domain object that does not map to a database column.
Originally Posted by PaoloValladolid
Sep 3rd, 2010, 08:37 AM
Mark the non-persistent field with @Transient annotation
Refer Javadocs of javax.persistence.Transient
Sep 7th, 2010, 10:19 AM
Thank you all. The @Transient annotation solved the issue.