org.hibernate.AnnotationException: Collection has neither generic type nor OneToMany.targetEntity()


Jeremy S:

I used Hibernate Tools to generate my Hibernate POJO mapping.

Unfortunately the code generated by the Hibernate tools doesn't seem to work, I get the exception

org.hibernate.AnnotationException: Collection has neither generic type nor OneToMany.targetEntity()

The part of the code that produces the exception is

/**
 * ClassFlag generated by hbm2java
 */
@Entity
@Table(name = "class_flag", catalog = "incbszdb")
public class ClassFlag implements java.io.Serializable {

    ....
    /* HERE */
    private Set classFlagI18ns = new HashSet(0);

    /* HERE */
    public void setClassFlagI18ns(Set classFlagI18ns) {
      this.classFlagI18ns = classFlagI18ns;
    }

}  

According to this article

http://www.mkyong.com/hibernate/org-hibernate-annotationexception-collection-has-nether-generic-type-or-onetomany-targetentity/comment-page-1/#comment-67404

and this article

http://www.mkyong.com/hibernate/hibernate-error-collection-has-ntwo-generic-type-or-onetomany-targetentity/

You have to manually change the code generated by Hibernates.

This is one thing I want to avoid. Any ideas what could be the problem?

greeting

JS

Jeremy S:

I found a working solution for me.

Just check "Use Java 5 Syntax" as shown in the attached screenshot and Hibernate Tools can generate the correct generic type for the collection.

enter image description here

Related


Hibernate retrieves null for OneToMany collection

tom My problem is that when fetching an instance on the following object , hibernate retrieves null in the value@OneToMany Set organizationMemberCollection: UserAccount.java: @Entity @Table(name="USER_ACCOUNT") public class UserAccount { @Id @Column(n

When reloading Slider, neither forward nor back has effect

Lucas Santos I am using bxSlider and in the following situation When a specific year is selected, I need to reload the month and just have the month in the clicked year value. My problem is that when reloading, I let go of the arrow controls, i.e., I can't mov

When reloading Slider, neither forward nor back has effect

Lucas Santos I am using bxSlider and in the following situation When a specific year is selected, I need to reload the month and just have the month in the clicked year value. My problem is that when reloading, I let go of the arrow controls, i.e., I can't mov

When reloading Slider, neither forward nor back has effect

Lucas Santos I am using bxSlider and in the following situation When a specific year is selected, I need to reload the month and just have the month in the clicked year value. My problem is that when reloading, I let go of the arrow controls, i.e., I can't mov