Note that there are some explanatory texts on larger screens.

plurals
  1. POHibernate, (netbeans 7.1.2, maven) unable to use ElementCollection attribute
    primarykey
    data
    text
    <p>A my SQL database has an "Item" table. Each "item" can have many alternate labels. These are stored in another table called "ItemAltLabel". The foreign key is “ItemID”.</p> <p>I am trying to represent this in java as an entity which has a set of string alternate labels.</p> <p>My property looks like this:</p> <pre><code>@ElementCollection @CollectionTable(name="ItemAltLabel", joinColumns=@JoinColumn(name="ItemID")) @Column(name="Label") private Set&lt;String&gt; alternateLabels; </code></pre> <p>Should this be correct?</p> <p>The error I get is:</p> <blockquote> <p>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityBroker': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: protected org.hibernate.SessionFactory com.porism.dao.BaseBroker.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/springmvc-servlet.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: Could not determine type for: java.util.Set, for columns: [org.hibernate.mapping.Column(Label)]</p> </blockquote> <p>I found this post, which suggests it is a bug in the version of hibernate I am using:</p> <p><a href="http://blog.m1key.me/2010/06/orghibernatemappingexception-could-not.html" rel="nofollow">http://blog.m1key.me/2010/06/orghibernatemappingexception-could-not.html</a></p> <p>“If you are getting this error in a similar situation, the reason is a bug in your Hibernate implementation and you should get a newer one (I recommend 3.5.3-Final or later).”</p> <p>My pom file refers to 3 hibernate dependencies:</p> <pre><code>&lt;dependency&gt; &lt;groupId&gt;org.hibernate&lt;/groupId&gt; &lt;artifactId&gt;hibernate&lt;/artifactId&gt; &lt;version&gt;3.2.5.ga&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.hibernate&lt;/groupId&gt; &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt; &lt;version&gt;3.3.2.GA&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.hibernate&lt;/groupId&gt; &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt; &lt;version&gt;3.3.2.GA&lt;/version&gt; &lt;/dependency&gt; </code></pre> <p>I have tried updating these to 3.5.3-Final (as the post suggests). </p> <p>My repositories look like this:</p> <p> http://ftp.ing.umu.se/mirror/eclipse/rt/eclipselink/maven.repo eclipselink default Repository for library Library[eclipselink] http://download.java.net/maven/2/ hibernate-support default Repository for library Library[hibernate-support] </p> <p>The error I get when trying to build the project is:</p> <blockquote> <p>Failed to execute goal on project InformWebServices: Could not resolve dependencies for project porism:InformWebServices:war:1.0: Could not transfer artifact org.hibernate:hibernate:jar:3.5.3-Final from/to eclipselink (http://ftp.ing.umu.se/mirror/eclipse/rt/eclipselink/maven.repo): Connection to <a href="http://ftp.ing.umu.se" rel="nofollow">http://ftp.ing.umu.se</a> refused: Connection timed out: connect -> [Help 1]</p> </blockquote> <p>If I remove the dependency on hibernate 3.5.3-Final, the other two dependencies are downloaded successfully. The project builds; but a new error appears:</p> <blockquote> <p>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityBroker': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: protected org.hibernate.SessionFactory com.porism.dao.BaseBroker.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/springmvc-servlet.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.cfg.AnnotationConfiguration</p> </blockquote> <p>I am using NetBeans 7.1.2 and maven.</p> <p>As you can probably tell, I have been handed a project, and don’t have a clue what I am doing. Any help would be greatly appreciated.</p> <p>I have tried upgrading to hibernate 4, but this resulted in a host of problems, and I would prefer to remain as close to the version I was using as possible.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload