Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) 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: 17309
11
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: 662
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.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!