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
|