Results 1 to 4 of 4

Thread: Want to add member to @Entity class that is not bound to column

  1. #1

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

  2. #2
    Join Date
    Jul 2010
    Posts
    26

    Default

    Quote Originally Posted by PaoloValladolid View Post
    Probably like many here, I have been using my 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)?
    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.

  3. #3
    Join Date
    May 2010
    Posts
    20

    Default

    Mark the non-persistent field with @Transient annotation
    Refer Javadocs of javax.persistence.Transient

  4. #4

    Default

    Thank you all. The @Transient annotation solved the issue.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •