-->
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: Hibernate annotation mapping question plz
PostPosted: Sat Oct 31, 2009 11:08 pm 
Newbie

Joined: Thu Oct 30, 2008 12:02 am
Posts: 5
Hi all

I just tested a small example getting the code from Hibernate. here is all relevant code.

[code]session.getTransaction().begin();
Car u = new SportCar();
u.setId(1);
session.saveOrUpdate(u);
session.getTransaction().commit();[/code]

[code]@Entity
@Table (name="Car")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "discrim", discriminatorType = DiscriminatorType.STRING)
public class Car {
@Id
private Integer id;

@Column (name = "discrim", insertable = false, updatable = false)
private String discrim;
...
[/code]

[code]@Entity
@DiscriminatorValue("sport")
public class SportCar extends Car{
...[/code]

When I run it, I have exception:
[code]Exception in thread "main" org.hibernate.MappingException: Unknown entity: au.chao.bo.SportCar
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:580)
at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1365)
at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:203)
at org.hibernate.event.def.AbstractSaveEventListener.getEntityState(AbstractSaveEventListener.java:535)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:103)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:534)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:526)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:522)
at au.chao.TestMain.main(TestMain.java:18)
[/code]

No idea why this happens, google for a while. can not find answer.

Anybody here can help?

Thanks
Steve


Top
 Profile  
 
 Post subject: Re: Hibernate annotation mapping question plz
PostPosted: Sat Oct 31, 2009 11:25 pm 
Newbie

Joined: Thu Oct 30, 2008 12:02 am
Posts: 5
Sorry guys, figure out myself.

Forgot update the mapping file :).


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.