Getters and Setters with hibernate annotation.

634 views
Skip to first unread message

Derek VerLee

unread,
Apr 18, 2012, 11:40:46 AM4/18/12
to project...@googlegroups.com
Thanks for the great tool,

I'm having a small issue.  Using Lombok 0.11.0 with Hibernate 3 and Eclipse, it does not appear to move the @Column annotation to the getter and hibernate appears to require this.  Is this expected? I've seen other people using @Column with @Data and it seems to work for them, but for me I get org.hibernate.DuplicateMappingException

Any thoughts?

_derek

Philip Healy

unread,
Apr 21, 2012, 3:01:08 PM4/21/12
to project...@googlegroups.com
Hi Derek,

From the Hibernate docs:

"Depending on whether you annotate fields or methods, the access type
used by Hibernate will be field or property. The EJB3 spec requires
that you declare annotations on the element type that will be
accessed, i.e. the getter method if you use property access, the field
if you use field access. Mixing annotations in both fields and methods
should be avoided. Hibernate will guess the access type from the
position of @Id or @EmbeddedId."

Either is fine for day-to-day use (I have used both in the past).
However, when using Lombok you will always be using field access
because you are annotating the fields directly. Hibernate does not
require method annotations. I am not sure what is causing the
DuplicateMappingException, perhaps you have an issue with your
persistence.xml?

Regards,
Philip

> --
> You received this message because you are subscribed to the Google
> Groups group for http://projectlombok.org/
>
> To post to this group, send email to project...@googlegroups.com
> To unsubscribe from this group, send email to
> project-lombo...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/project-lombok?hl=en

Reply all
Reply to author
Forward
0 new messages