-->
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: Unioned Subclasses with Conflicting Column Types
PostPosted: Thu May 10, 2007 6:05 am 
Newbie

Joined: Thu May 10, 2007 5:16 am
Posts: 1
Hello All,

I am in the process of migrating an existing object model and data model to use Hibernate, replacing a legacy ORM framework.

The object model and data model use/require a TABLE_PER_CLASS inheritance model.

The problem I have encountered is that the union select query generated by Hibernate is not detecting conflicting data types if the concrete classes define the same column name with a different SQL type.

For example:

@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class ParentClass {
@Id
private Long id;
}

@Entity
@Table(name = "CHILDA")
public class ChildA extends ParentClass {
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "SOMEDATE")
private Date someDate;
}

@Entity
@Table(name = "CHILDB")
public class ChildB extends ParentClass {
@Temporal(TemporalType.DATE)
@Column(name = "SOMEDATE")
private Date someDate;
}

The problem is that the union query generated will result in something like:

select somedate from childa
union all
select somedate from childb

In DB2 executing this query results in a SQL state 42825, i.e. ambiguous types returned in the union statement, somedate is DATE in one statement and is TIMESTAMP in the other.

My question is has anyone else experienced something similar when using union subclasses and if so how did you overcome the problem?

I acknowledge that it is a rather stupid scenario, the object model designers should have called the properties/columns SOMEDATE and SOMETIMESTAMP. Unfortunately I have to live with the design in the interim and I believe using Hibernate with legacy models that include such flaws is definitely a problem that Hibernate should be able to tackle!


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.