I reference to a composite key, so this could be the problem:
But when I delete the reference from my Entity "Container",
then the hibernate-mapping does not complain any mapping-failure,
that means all my referenceColumns (and my composite keys) are right.
Both the "name" and the "referencedColumnName" should be the names of the corresponding SQL-Columns,
that means in my SQL-Table CONTAINER the column "ID_CONTAINER" is declared as a PrimaryKey and in
in my SQL-Table CONTENT column "ID_CONTAINER" is declared as a ForeignKey (and PrimaryKey).
So I do not reference via JAVA-Attributes as this would be wrong! Am I right?
referencedColumnName should be definitlythe name of the corresponing (sql-)column
and not the name of the corresponding property! In the Hibernate-Manual, the SQL-Column is used!
But this does not help me out. I cannot find a solution for my problem.
Stefan Goor
Greenhorn
Joined: Dec 21, 2009
Posts: 1
posted
0
I had the same issue but found it was caused by where the @ManyToOne and @JoinColumn annotations were placed.
Generally I work with generated code for hibernate objects so the annotations are placed above the getter methods in the generated Java code, however when I tried to add some annotations to someone else's manually written hibernate code I got the error:
After being baffled for a while I noticed that the class I was modifying had all the other existing annotations on the private member variables. When I moved my annotations away from the getter method and onto the private member variable the errors disappeared and seemed to work as expected.
Hope this helps...
Hernan Lopez
Greenhorn
Joined: Jul 31, 2004
Posts: 1
posted
0
Stiofan Uí Goida wrote:I had the same issue but found it was caused by where the @ManyToOne and @JoinColumn annotations were placed.
Generally I work with generated code for hibernate objects so the annotations are placed above the getter methods in the generated Java code, however when I tried to add some annotations to someone else's manually written hibernate code I got the error:
After being baffled for a while I noticed that the class I was modifying had all the other existing annotations on the private member variables. When I moved my annotations away from the getter method and onto the private member variable the errors disappeared and seemed to work as expected.
Hope this helps...
Thanks Goida It works for me.
Filip Saska
Greenhorn
Joined: Oct 26, 2011
Posts: 1
posted
0
I had the same problem. In my case the solution was adding an anntation @CollectionOfElements to he getter method (that's where i keep my annotations). Once i discovered this, it was a piece of cake Hope it helps