-->
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.  [ 1 post ] 
Author Message
 Post subject: DiscriminatorColumn value not included in insert sql
PostPosted: Tue Mar 23, 2010 12:20 pm 
Newbie

Joined: Tue Mar 23, 2010 12:06 pm
Posts: 1
Hi!

I am using JPA over Hibernate and I have a problem with inserting (MySql DB) Entity object with the following inheritance hierarchy:

Code:
@Entity
@Table(name="asset")
@Inheritance(strategy=InheritanceType.JOINED)
@DiscriminatorColumn(name="Type", discriminatorType=DiscriminatorType.INTEGER)
public abstract class Asset implements Serializable {

   private int id;
   private String description;
   private boolean isAvailable;
   private String name;

   ...
}

@Entity
@Table(name="vehicle")
@DiscriminatorValue("1")
public class Vehicle extends Asset implements Serializable {
   ...
}

When calling persist method on EntityManager, the generated sql is:
Code:
Hibernate: insert into asset (Description, IsAvailable, Name) values (?, ?, ?)

Since 'Type' column is NOT NULL, insert fails due to missing parameter.

What am I missing?

Thanks in advance.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.