-->
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: JPA and hibernate Problem with InheritanceType.SINGLE_TABLE
PostPosted: Wed Mar 26, 2008 8:48 pm 
Beginner
Beginner

Joined: Mon Nov 29, 2004 5:34 pm
Posts: 35
Hi,
I am trying to figure this error and I have already spend lot of time, Please help me in this.

I have Action class, which looks like this

Code:
@Entity
@Table(name = "BATCH_ACTION")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "ACTN_TYPE", discriminatorType = DiscriminatorType.INTEGER)

public class Action extends BaseObject
{

}


And the subclass which is extends the Action class

Code:
@Entity
@DiscriminatorValue("3")
public class ExtractCompletedAction extends Action
{
}


In my business layer of code, I was creating new action.
Code:
Action newAction = new Action();

And setting all the required attributes.


And when I retrieve the batch object from database using hibernate createCriteria every thing looks good. It also get the actions based on the discriminator column value. In the above case all having value 3

Problem/Issue
When I try to save the object new action, the type (ACTN_TYPE used on Discriminator column) has value = 1955883606 in the database.
I was expecting 3 (Since that was there in my DiscriminatorValue value)

_________________
My Forte 4GL and Spring Blog

srigold


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 26, 2008 9:07 pm 
Newbie

Joined: Thu May 17, 2007 9:49 am
Posts: 9
Discriminator with value 3 is binded with ExtractCompletedAction entity. I think you should create it like that:
Code:
Action newAction = new ExtractCompletedAction();


Top
 Profile  
 
 Post subject: Got error doing that.
PostPosted: Wed Mar 26, 2008 9:58 pm 
Beginner
Beginner

Joined: Mon Nov 29, 2004 5:34 pm
Posts: 35
Hi,
Thanks for quick reply, I tried different options and this was were I was stuck.
I tried before and I changed the code now as you said. I got following error.

Quote:
newAction = new ExtractStartedAction("EXTRACT_STARTED");


Code:
org.springframework.orm.hibernate3.HibernateSystemException: Unknown entity: com.xxx.abc.model.ExtractSkippedAction; nested exception is org.hibernate.MappingException: Unknown entity: com.xxx.abc.model.ExtractSkippedAction





Please let me know, any other thought in resolving this error.

_________________
My Forte 4GL and Spring Blog

srigold


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 27, 2008 3:38 pm 
Beginner
Beginner

Joined: Mon Nov 29, 2004 5:34 pm
Posts: 35
I have solved my problem.

I have the super class

Code:
@Entity
@Table(name = "BATCH_ACTION")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "ACTN_TYPE", discriminatorType = DiscriminatorType.INTEGER)
public class Action extends BaseObject
{

}


and other sub class

Code:
@Entity
@DiscriminatorValue("3")
public class ExtractCompletedAction extends Action
{
}


I added all the sub classes in hibernate.hbm.xml file, then it worked.

_________________
My Forte 4GL and Spring Blog

srigold


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.