This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Three Table/Class Combination Display?

 
Edward Durai
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Arun Kumarr
Ranch Hand
Posts: 661
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic