aspose file tools*
The moose likes Object Relational Mapping and the fly likes Three Table/Class Combination Display? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Three Table/Class Combination Display?" Watch "Three Table/Class Combination Display?" New topic
Author

Three Table/Class Combination Display?

Edward Durai
Ranch Hand

Joined: Oct 09, 2004
Posts: 223
Hi,

I have 3 tables in MSSQL Database.

1. Auditfinding
2. AuditfindingsDisplayName
3. AuditFindingsFieldList

Fine. I have Created Mapping Files And Java Bean files(Using getter and setter methods)

My Hibernate Query is Working Perfectly.

My Query is:

select distinct Id as AuditId,substring(substring(CustomIssueField, patindex('%data_27="%',CustomIssueField)+9 ,len(CustomIssueField)),1,patindex('%"%',substring(CustomIssueField, patindex('%data_27="%',CustomIssueField)+9 ,len(CustomIssueField)))-1) as [CustomIssueField], DisplayName from Auditfindingsfieldlist X,Auditfindingsdisplayname Y, Auditfinding where x.fieldid>25 and y.fieldid=x.fieldid

Code is:
======================================================
SQLQuery query = session.createSQLQuery("select distinct Id, substring(substring(CustomIssueField, patindex('%data_27=\"%',CustomIssueField)+9 ,len(CustomIssueField)),1,patindex('%\"%',substring(CustomIssueField, patindex('%data_27=\"%',CustomIssueField)+9 ,len(CustomIssueField)))-1) as [CustomIssueField], DisplayName from Auditfindingsfieldlist X,Auditfindingsdisplayname Y, Auditfinding where x.fieldid>25 and y.fieldid=x.fieldid");

query.addScalar("Id",Hibernate.INTEGER);
query.addScalar("CustomIssueField",Hibernate.STRING);
query.addScalar( "DisplayName", Hibernate.STRING);
usrlist = query.list();
=================================================
I am Using Three tables from above

The result is display like

[Ljava.lang.Object;@24bef5
[Ljava.lang.Object;@74d22e
[Ljava.lang.Object;@192ee25
[Ljava.lang.Object;@150cf54
[Ljava.lang.Object;@5bc8c9

I want to display id, customissuefield, displayname

How can I fetch from List (List contains combines three tables/classes)

Thanks
edward


Thank You<br />Edward
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17259
    
    6

So if there are relationships defined in your mapping between the three tables, you can either do SQL, HQL or Criteria Object, and query on one of the tables and traverse to the other objects in the Object graph.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Arun Kumarr
Ranch Hand

Joined: May 16, 2005
Posts: 513

when you do an aggregation of data from tables, we typically get an array of objects, like Object[][];
Object[0][1] will be Integer
Object[0][2] will be String
Object[0][3] will be String

you can typecast them to corresponding objects(Integers, Strings) and use them.


If you are not laughing at yourself, then you just didn't get the joke.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Three Table/Class Combination Display?