-->
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: is it possble: SELECT A1,A2,A3 FROM A, An is subclass of A
PostPosted: Mon Oct 20, 2003 4:42 am 
Newbie

Joined: Mon Oct 20, 2003 4:36 am
Posts: 4
suppose A has three or more subclasses: A1, A2,A3...
If I use "from A" I can get all its subclasses, but I wanna
distingish those subclasses and display them in diff format
in a report, I have no idea how.

If I can use " select A1,A2... from A", then it'll be easy for
me to understand and handle those subclasses seperately.
I tried and failed. could tell me how.


Top
 Profile  
 
 Post subject: possibilities
PostPosted: Mon Oct 20, 2003 11:37 am 
Regular
Regular

Joined: Tue Sep 16, 2003 11:35 am
Posts: 93
Location: San Francisco, CA
you could ...

select from A, then loop over the list results and use instanceof to figure out what subclass it is and act accordingly,

issue a select statement for each subclass individually,

encapsulate the display information in each class so you could just select from A and then call o.display() for each instance, each subclass would know how to display itself.

It doesn't look like what you were trying to do is legal SQL syntax.


Top
 Profile  
 
 Post subject: Re: possibilities
PostPosted: Mon Oct 20, 2003 4:40 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
cutie wrote:
select from A, then loop over the list results and use instanceof to figure out what subclass it is and act accordingly,

Won't work if you use proxy for lazy initialization (see 11.1 of hibernate reference guide)

_________________
Emmanuel


Top
 Profile  
 
 Post subject: one more question
PostPosted: Tue Oct 21, 2003 2:01 am 
Newbie

Joined: Mon Oct 20, 2003 4:36 am
Posts: 4
I try to use seperated "select". now the problem is after I get the result set, I have to split them into diff group according to their status(there is a status field in the table), and display the result set grouped by status. I wonder how to map the table so that I needn't manually group the resultset.

the report is like the following
Code:
status1:
       A1 description 
             A11
             A12
             A13
             ...
             A1n

       A2 description
             A21
             A22
             ...
             A2n

status2:
       A1 description 
             A11
             A12
             A13
             ...
             A1n

       A2 description
             A21
             A22
             ...
             A2n
...



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.