-->
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.  [ 4 posts ] 
Author Message
 Post subject: Mapping Exception with Annotations
PostPosted: Tue Mar 27, 2007 2:39 am 
Newbie

Joined: Tue Mar 27, 2007 2:04 am
Posts: 4
Hi all,

I am using hibernate annotations and am not using hbm mapping files. When I insert and save data in DB through my persistence class 'UserResume', I get following error


Exception in thread "main" org.hibernate.MappingException: Unknown entity: candidate.UserResume
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:550)
at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1338)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:98)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:519)
at candidate.SaveAndRetrieveResume.main(SaveAndRetrieveResume.java:45)



As far as i know we get this error when no mapping file is found but as I am using annotations, I dont require hbm.xml for UserResume.java.
Please help me.....


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 27, 2007 6:53 am 
Newbie

Joined: Thu Oct 28, 2004 1:15 am
Posts: 8
Could paste in your UserResume class?

Regards,
Søren


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 27, 2007 8:16 am 
Newbie

Joined: Tue Mar 27, 2007 2:04 am
Posts: 4
code for my mapping is:

<mapping class="candidate.UserResume" />


and my UserResume class is below:


package candidate;

import java.sql.Blob;
import org.hibernate.annotations.*;
import javax.persistence.Column;
import javax.persistence.Lob;
import javax.persistence.Table;


@Entity
@Table(name = "user_resume")
public class UserResume {

private String resumeId;
private Blob resumeBlob;
private String userId;

@Column(name = "resume_blob")
@Lob
public Blob getResumeBlob() {
return resumeBlob;
}
public void setResumeBlob(Blob resumeBlob) {
this.resumeBlob = resumeBlob;
}

@Column(name = "resume_id", unique = true, nullable = false, insertable = true, updatable = false)
public String getResumeId() {
return resumeId;
}
public void setResumeId(String resumeId) {
this.resumeId = resumeId;
}

@Column(name = "user_id", unique = true, nullable = false, insertable = true, updatable = false)
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}

}


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 28, 2007 12:55 am 
Newbie

Joined: Tue Mar 27, 2007 2:04 am
Posts: 4
I got it....

I was using Entity from package org.hibernate.annotations whereas I was supposed to use it from package javax.persistence.

thanks anyways.


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