Hibernate Persistence model warnings
Hello,
I have a really annoying issue in some of my entity classes. Perhaps this is old news for some people but I haven't figured out how to solve this. A lot classes have "<many-to-one> attribute target should be entity" and "<one-to-many> attribute target should be entity" errors. Actually they're just warnings because everything goes ok at compile time and runtime. I only get these on getter methods. Could you please tell me what am I missing or what extra configuration should I make in order to resolve these warnings?
Here is an example of two relationships that generate such warnings:
The hibernate configuration file:
<hibernate-mapping>
<class name="com.treert.people.Person" table="Person">
....
<many-to-one name="primaryName" column="Primary_Name_Id" cascade="save-update"/>
<set name="names" cascade="save-update">
<key column="Person_Id"/>
<one-to-many />
</set>
</class>
</hibernate-mapping>
The getters in the Person class:
-- this is one of the methods that generates a "<many-to-one> attribute target should be entity" warning
public Name getPrimaryName() {
return primaryName;
}
-- this is one of the methods that generates a "<one-to-many> attribute target should be entity" warning
public Set<Name> getNames() {
return names;
}
Thank you ...
请先登录再写评论。
Does com.treert.people.Name have any mapping metadata in XML or Java?
If IDEA recognize it as an entity a corresponding node should appear in
JavaEE:Structure view under hibernate facet/session factory/.
Florin H wrote:
Hello Gregory,
This is how the name.hbm.xml file looks like:
<hibernate-mapping>
<class name="com.treert.people.Name" table="Name">
<id name="id" column="Id" type="long"><generator /></id>
<many-to-one name="person" column="Person_Id" cascade="save-update"/>
</class>
</hibernate-mapping>
The Name class has no metadata, it is a simple POJO.
" If IDEA recognize it as an entity a corresponding node should appear in JavaEE:Structure view under hibernate facet/session factory/." Where exactly is this JavaEE:Structure or the hibernate facet/session factory/?
Project Structure toolwindow has a dropdown box with Javaee:Structure
option.
name.hbm.xml & person.hbm.xml should be present in Hibernate facet if
they are present in ]]> in the hibernate.cfg.xml.
Name & Person objects should be there as well.
Florin H wrote: