-->
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: @DiscriminatorColumn is not considered in DELETE HQL query
PostPosted: Mon Nov 06, 2006 1:52 pm 
Newbie

Joined: Sun Nov 05, 2006 5:57 pm
Posts: 1
Hello,

i have problem when deleting all records of entities that share the same table and have the same @MappedSuperclass. It seems that HQL query DELETE <entity_name>
does not consider @DiscriminatorColumn property and deletes all records from underlying table (also sibling entities)

Here are entity definitions:
Code:
@MappedSuperclass
public abstract class AbstractTransaction implements Serializable
{
  protected Long id;
...

@Entity(name="TRANSACTION")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="TRANSACTION_TYPE", discriminatorType=DiscriminatorType.STRING)
@DiscriminatorValue("Deposit")
public class Deposit extends AbstractTransaction
{
...

Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="TRANSACTION_TYPE", discriminatorType=DiscriminatorType.STRING)
@DiscriminatorValue("Transaction")
public class Transaction extends AbstractTransaction
{


Java code:
Code:
String query = "DELETE banking.entity.Transaction";
int rowCount = session.createQuery(query).executeUpdate();
...
String query = "DELETE banking.entity.Deposit";
int rowCount = session.createQuery(query).executeUpdate();


SQL log:
Code:
INFO:   Deleting all banking.entity.Transaction
Hibernate: delete from Transaction

INFO:   Deleting all banking.entity.Deposit
Hibernate: delete from TRANSACTION


Is there something I misunderstood?
Can anybody explain why the HQL query is translated that way?
Is it a bug?

Thanks for any reply.

Michal Galet


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 07, 2006 8:09 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
@ForceDiscriminator

_________________
Emmanuel


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.