-->
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: Differences Between Joined and Table_per_Class
PostPosted: Wed Nov 18, 2009 12:49 pm 
Newbie

Joined: Mon Feb 23, 2009 11:16 am
Posts: 17
Hi,

I have a semi-complex (overly complex really) structure of classes that inherit from each other. Basically it's an @Entity Abstract Class which is extended by about 6 other types of classes, all of which are also @Entity types. For some reason if I map the Abstract Class with inheritance based on Table_per_class I receive the following error when selecting (using criteria) against one of its sub types:

"Caused by: java.sql.SQLException: Types 'VARCHAR' and 'INTEGER' are not UNION compatible."

However if I change the inheritance mapping to JOINED then the error goes away and my code works just fine. (When I say works I mean there is a JUnit test that checks all the values of the loaded class and validates them so I know this is working with JOINED)


More details:

The base Abstract Class defines many different columns while the sub types simply add an additional column or two as well as a @OneToMany or a @ManyToMany relationship.

One of these subtypes has a @ManyToMany that is mapped to a targetEntity of the Abstract Class itself. When I do a NaturalId based Criteria search for this particular subtype the queries become very long, complex, and difficult to understand. From what I can see it selects from all of the possibly sub types and does a UNION ALL between all of the selects. These selects consist of all possible fields (with Nullif(0,0) for possibly non-existant fields) however they are clearly not all the same type. Many of my fields are String, many others are Integers. The final select does the actual foreign key checking and that all looks fine as well.

Unfortunately, according to the error, a UNION ALL cannot be used across different column types. Is this true? If so does this appear to be a Hibernate bug or a mistake on my part?

Apologies if there is any lack of detail but I think it should be pretty clear to someone with more SQL experience than me as to whether or not this sounds like a Hibernate bug and simply providing my code would only lead to confusion (my base type has something like 16 fields) unless I wrote minimal-bug testing code which I plan to if this appears to be a bug.


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.