hi,
I use spring 2.5.5 with hibernate jars that come with the distribution and java 1.5_18
I WANT to use annotations :
and this :Code:import java.util.List; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.OneToMany; import javax.persistence.Table; @Entity @Table(name="trunkgroups") public class Trunkgroup { private int trunkgroup; private String name; private boolean valid; public Trunkgroup(){} @Id @GeneratedValue(strategy=GenerationType.AUTO) public int getTrunkgroup() { return trunkgroup; } public void setTrunkgroup(int trunkgroup) { this.trunkgroup = trunkgroup; } @Column(name="name") public String getName() { return name; } public void setName(String name) { this.name = name; } @Column(name="valid") public boolean isValid() { return valid; } public void setValid(boolean valid) { this.valid = valid; } }
when I deploy the application I get :Code:<bean name="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource"><ref local="dataSource"/></property> <property name="annotatedClasses"> <list> <value>com.xxx.model.domain.Trunkgroup</value> </list> </property> <property name="annotatedPackages"> <list> <value>com.xxx.model.domain</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.jdbc.batch_size">10</prop> <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop> <prop key="hibernate.cache.use_second_level_cache">false</prop> <prop key="hibernate.cache.use_query_cache">false</prop> </props> </property> </bean>
What do I missed ?Code:Caused by: org.hibernate.AnnotationException: No identifier specified for entity: com.xxx.model.domain.Trunkgroup [21:02:04.484] at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:671) [21:02:04.484] at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:529) [21:02:04.484] at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:281) [21:02:04.484] at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1125) [21:02:04.484] at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:673) [21:02:04.484] at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211) [21:02:04.484] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1368) [21:02:04.484] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1334) [21:02:04.484] ... 63 more
I know that the javax.persistence annotations have runtime retention.
What happens that it doesn;t see the @Id. I looked in hibernate faq and there says that @Id must be set...well... I set it... .
Can someone help ? I'm in a big hurry, thanks.
regards,
Viorel


Reply With Quote