-->
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.  [ 5 posts ] 
Author Message
 Post subject: [solved] persistent class not known: long
PostPosted: Mon Mar 22, 2010 9:14 am 
Newbie

Joined: Mon Mar 22, 2010 8:34 am
Posts: 4
Hello.
I am getting this error
Code:
org.hibernate.MappingException: persistent class not known: long
     at org.hibernate.cfg.Configuration$1.getIdentifierType(Configuration.java:2109)
     at org.hibernate.type.EntityType.getIdentifierType(EntityType.java:487)
     at org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(EntityType.java:512)
     at org.hibernate.persister.entity.AbstractPropertyMapping.initIdentifierPropertyPaths(AbstractPropertyMapping.java:169)
     at org.hibernate.persister.entity.AbstractPropertyMapping.initPropertyPaths(AbstractPropertyMapping.java:159)
     at org.hibernate.persister.entity.AbstractEntityPersister.initOrdinaryPropertyPaths(AbstractEntityPersister.java:1712)
     at org.hibernate.persister.entity.AbstractEntityPersister.initPropertyPaths(AbstractEntityPersister.java:1742)
     at org.hibernate.persister.entity.AbstractEntityPersister.postConstruct(AbstractEntityPersister.java:2919)
     at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:409)
     at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
     at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
     at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1300)
     at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
...
I am using annotations on the getters like this
Code:
@Id
@GeneratedValue
public Long getId() {
   return id_;
}
and have the class mapped in cfg.
Code:
<mapping class="entity.Application"></mapping>
I don't know if I have missed anything that is needed?

I initially had the id as long when I got the error and then changed it to Long but the message stayed the same after mvn clean.

Thanks.


Last edited by erikbalek on Tue Mar 23, 2010 3:20 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: persistent class not known: long
PostPosted: Mon Mar 22, 2010 2:35 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
Quote:
I don't know if I have missed anything that is needed?


Please submit more information, for example the complete mapping/code with annotations for your class. I would think that you have mapped an association to Long and not to another entity.


Top
 Profile  
 
 Post subject: Re: persistent class not known: long
PostPosted: Mon Mar 22, 2010 3:57 pm 
Newbie

Joined: Mon Mar 22, 2010 8:34 am
Posts: 4
Code:
@Entity
@Table(name = "APPLC", catalog = "assoc")
public class Application {

   private Long id_;
   private String applicationCode_ = "app1";

   public Application() {
      setId(new Long(1));
   }
   
   public void setId(Long id) {
     id_ = id;
   }

   @Id
   @GeneratedValue(strategy = GenerationType.AUTO)
   @Type(type = "java.lang.Long")
   public Long getId() {
     return id_;
   }

   public void setApplicationCode(String applicationCode) {
     applicationCode_ = applicationCode;
   }

   @Column(name = "NAME", nullable = false)
   public String getApplicationCode() {
     return applicationCode_;
   }
}

---

@Entity
@Table(name = "ORGUA", catalog = "assoc")
public class OrgUnitApp {
   
   private Long id_;   
   private Application application_;
   private OrgUnit orgUnit_;

   public OrgUnitApp() {   
   }   

   public void setId(Long id) {
     id_ = id;
   }

   @Id
   @GeneratedValue(strategy = GenerationType.AUTO)
   @Type(type = "java.lang.Long")
   public Long getId() {
     return id_;
   }

   public void setApplication(Application application) {
     application_ = application;
   }

   @OneToOne(cascade = CascadeType.ALL) //cascade?
   @PrimaryKeyJoinColumn
   public Application getApplication() {
     return application_;
   }

   public void setOrgUnit(OrgUnit orgUnit) {
     orgUnit_ = orgUnit;
   }

   @OneToOne(cascade = CascadeType.ALL)
   @PrimaryKeyJoinColumn
   public OrgUnit getOrgUnit() {
     return orgUnit_;
   }
}

---

<hibernate-configuration>
<session-factory>
<property name="hibernate.bytecode.use_reflection_optimizer">false</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>

<!-- create missing tables on the fly during development -->
<property name="hibernate.hbm2ddl.auto">create-drop</property>
<property name="hibernate.connection.password">pwd</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/assoc</property>
<property name="hibernate.connection.username">erik</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
<property name="show_sql">true</property>
<mapping class="entity.Application"/>
<mapping class="entity.OrgUnitApp"/>
...
</session-factory>
</hibernate-configuration>

I have a few of these classes, all mapped in the same way, simple one-to-one.
Thanks again.


Top
 Profile  
 
 Post subject: Re: persistent class not known: long
PostPosted: Mon Mar 22, 2010 4:50 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
I am not so familiar with annotations or one-to-one mappings but I can't find anything that seems incorrect. Are you sure that the error is related to one of the classes you have posted. You can turn on logging as described in the documentation to get detailed information about what Hibernate is doing: http://docs.jboss.org/hibernate/stable/ ... on-logging


Top
 Profile  
 
 Post subject: Re: persistent class not known: long
PostPosted: Tue Mar 23, 2010 3:19 am 
Newbie

Joined: Mon Mar 22, 2010 8:34 am
Posts: 4
You are correct, Sir!
I discovered a leftover property that was still a long frrom an earlier code. Sloppy refactoring on my part. Sorry for the trouble and thanks again!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.