-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: No identifier specified for entity
PostPosted: Mon Jan 04, 2010 5:24 am 
Newbie

Joined: Sat Aug 25, 2007 5:36 am
Posts: 7
Hi all,

I tried to implement an application using hibernate.
My class(Entity) is as simple as the following:
Code:
import javax.persistence.Entity;
import javax.persistence.Id;

@Entity
public class Test {
   
   @Id
   private int id;

   private String name;
   
   public int getId() {
      return id;
   }
   public void setId(int id) {
      this.id = id;
   }
   public String getName() {
      return name;
   }
   public void setName(String name) {
      this.name = name;
   }
}


My hibernate.cfg.xml contains the following:
Code:
<property name="hibernate.bytecode.use_reflection_optimizer">true</property>       
      <property name="hibernate.jdbc.batch_size">50</property>
        <property name="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
      <property name="hibernate.cache.use_second_level_cache">false</property>
      <property name="hibernate.cache.use_query_cache">false</property>
      <property name="current_session_context_class">thread</property>
      <property name="hibernate.show_sql">false</property>
      <property name="hibernate.use_sql_comments">false</property>
      <property name="hibernate.max_fetch_depth">3</property>

      <mapping class="de.Test"/>


The hibernate.properties looks like this:
Code:
hibernate.connection.username=postgres
hibernate.connection.password=postgres
hibernate.connection.driver_class=org.postgresql.Driver
hibernate.connection.url=jdbc:postgresql://localhost:5432/test
hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
connection.pool_size=3
hibernate.dbcp.validationQuery=SELECT 1+1


When I try to build my session factory I always get this exception:
No identifier specified for entity

Does anyone of you know, what I did wrong...


Top
 Profile  
 
 Post subject: Re: No identifier specified for entity
PostPosted: Mon Jan 04, 2010 9:43 am 
Newbie

Joined: Sat Aug 25, 2007 5:36 am
Posts: 7
Hi,

I checked something and found out, that it works if I write the Annotation in front of the getter.
But I would like to have it at the variable.

I tried to use
Code:
@AccessType("field")
but it didn't work ( I tried
Code:
@AccessType("property")
, too).
I think the @AccessType is ignored, but I don't know why...

Can anyone help me?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.