-->
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: i have a problem with many-to-many
PostPosted: Thu Jun 28, 2007 8:32 am 
Newbie

Joined: Wed Feb 14, 2007 11:19 pm
Posts: 3
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
2
Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:
No exceptions

Name and version of the database you are using:
mysql5
The generated SQL (show_sql=true):
Hibernate: select customerty0_.UID as UID0_, customerty0_.NAME as NAME0_, customerty0_.DESCRIPTION as DESCRIPT3_0_, customerty0_.SEQ as SEQ0_ from CUSTTYPE customerty0_ where customerty0_.UID=?
Hibernate: select serviceoff0_.UID as UID5_, serviceoff0_.START_DATE as START_DATE5_, serviceoff0_.END_DATE as END_DATE5_, serviceoff0_.ACTIVE as ACTIVE5_, serviceoff0_.NAME as NAME5_, serviceoff0_.DESCRIPTION as DESCRIPT6_5_, serviceoff0_.SERVICE_OFFICER_TYPE_FK as SERVICE_7_5_, serviceoff0_.USER_ORG_FK as USER_ORG8_5_, serviceoff1_.UID as UID0_, serviceoff1_.NAME as NAME0_, serviceoff1_.DESCRIPTION as DESCRIPT3_0_, serviceoff1_.SEQ as SEQ0_, userorgimp2_.UID as UID1_, userorgimp2_.NAME as NAME1_, userorgimp2_.ACCOUNT as ACCOUNT1_, userorgimp2_.ETR_REF_COMPANY_ID as ETR_REF_4_1_, userorgimp2_.BRANCH_NAME as BRANCH_N5_1_, userorgimp2_.GROUP_ID as GROUP_ID1_, userorgimp2_.CTOS_COMP_CODE as CTOS_COM7_1_, userorgimp2_.CTOS_ACC_CODE as CTOS_ACC8_1_, userorgimp2_.CTOS_USER_ID as CTOS_USE9_1_, userorgimp2_.CTOS_PSWD as CTOS_PSWD1_, userorgimp2_.CUST_ORG_QUOTA as CUST_OR11_1_, userorgimp2_.BUSINESS_NATURE as BUSINES12_1_, userorgimp2_.MON_EMAIL1 as MON_EMAIL11_, userorgimp2_.MON_EMAIL2 as MON_EMAIL21_, userorgimp2_.MON_EMAIL3 as MON_EMAIL31_, userorgimp2_.MON_EMAIL4 as MON_EMAIL41_, userorgimp2_.MON_EMAIL5 as MON_EMAIL51_, userorgimp2_.USER_ORG_TYPE_FK as USER_OR18_1_, userorgimp2_.ORGANISATION_FK as ORGANIS19_1_, userorgimp2_.ORG_LEVEL_FK as ORG_LEV20_1_, userorgimp2_.PARENT_ORG_FK as PARENT_21_1_, userorgtyp3_.UID as UID2_, userorgtyp3_.NAME as NAME2_, userorgtyp3_.DESCRIPTION as DESCRIPT3_2_, userorgtyp3_.LEVEL as LEVEL2_, userorgtyp3_.SEQ as SEQ2_, organisati4_.UID as UID3_, organisati4_.ACTIVE as ACTIVE3_, organisati4_.EXPIRY_DATE as EXPIRY_D4_3_, organisati4_.NAME as NAME3_, organisati4_.CREATE_DATE as CREATE_D6_3_, organisati4_.CREATE_BY as CREATE_BY3_, organisati4_.MODIFY_DATE as MODIFY_D8_3_, organisati4_.MODIFY_BY as MODIFY_BY3_, organisati4_.PARTY_TYPE_FK as PARTY_T10_3_, orglevelim5_.ORGLEVELUID as ORGLEVEL1_4_, orglevelim5_.NAME as NAME4_, orglevelim5_.DESCRIPTION as DESCRIPT3_4_, orglevelim5_.LEVEL as LEVEL4_ from SERVOFF serviceoff0_ left outer join SERVOFFTYPE serviceoff1_ on serviceoff0_.SERVICE_OFFICER_TYPE_FK=serviceoff1_.UID left outer join USERORG userorgimp2_ on serviceoff0_.USER_ORG_FK=userorgimp2_.UID left outer join USERORGTYPE userorgtyp3_ on userorgimp2_.USER_ORG_TYPE_FK=userorgtyp3_.UID left outer join PARTY organisati4_ on userorgimp2_.ORGANISATION_FK=organisati4_.UID left outer join ORGLEVEL orglevelim5_ on userorgimp2_.ORG_LEVEL_FK=orglevelim5_.ORGLEVELUID where serviceoff0_.UID=?
Hibernate: select partytypei0_.UID as UID0_, partytypei0_.NAME as NAME0_, partytypei0_.DESCRIPTION as DESCRIPT3_0_, partytypei0_.CODE as CODE0_, partytypei0_.SEQ as SEQ0_ from PARTYTYPE partytypei0_ where partytypei0_.UID=?
Hibernate: select serviceoff0_.UID as UID5_, serviceoff0_.START_DATE as START_DATE5_, serviceoff0_.END_DATE as END_DATE5_, serviceoff0_.ACTIVE as ACTIVE5_, serviceoff0_.NAME as NAME5_, serviceoff0_.DESCRIPTION as DESCRIPT6_5_, serviceoff0_.SERVICE_OFFICER_TYPE_FK as SERVICE_7_5_, serviceoff0_.USER_ORG_FK as USER_ORG8_5_, serviceoff1_.UID as UID0_, serviceoff1_.NAME as NAME0_, serviceoff1_.DESCRIPTION as DESCRIPT3_0_, serviceoff1_.SEQ as SEQ0_, userorgimp2_.UID as UID1_, userorgimp2_.NAME as NAME1_, userorgimp2_.ACCOUNT as ACCOUNT1_, userorgimp2_.ETR_REF_COMPANY_ID as ETR_REF_4_1_, userorgimp2_.BRANCH_NAME as BRANCH_N5_1_, userorgimp2_.GROUP_ID as GROUP_ID1_, userorgimp2_.CTOS_COMP_CODE as CTOS_COM7_1_, userorgimp2_.CTOS_ACC_CODE as CTOS_ACC8_1_, userorgimp2_.CTOS_USER_ID as CTOS_USE9_1_, userorgimp2_.CTOS_PSWD as CTOS_PSWD1_, userorgimp2_.CUST_ORG_QUOTA as CUST_OR11_1_, userorgimp2_.BUSINESS_NATURE as BUSINES12_1_, userorgimp2_.MON_EMAIL1 as MON_EMAIL11_, userorgimp2_.MON_EMAIL2 as MON_EMAIL21_, userorgimp2_.MON_EMAIL3 as MON_EMAIL31_, userorgimp2_.MON_EMAIL4 as MON_EMAIL41_, userorgimp2_.MON_EMAIL5 as MON_EMAIL51_, userorgimp2_.USER_ORG_TYPE_FK as USER_OR18_1_, userorgimp2_.ORGANISATION_FK as ORGANIS19_1_, userorgimp2_.ORG_LEVEL_FK as ORG_LEV20_1_, userorgimp2_.PARENT_ORG_FK as PARENT_21_1_, userorgtyp3_.UID as UID2_, userorgtyp3_.NAME as NAME2_, userorgtyp3_.DESCRIPTION as DESCRIPT3_2_, userorgtyp3_.LEVEL as LEVEL2_, userorgtyp3_.SEQ as SEQ2_, organisati4_.UID as UID3_, organisati4_.ACTIVE as ACTIVE3_, organisati4_.EXPIRY_DATE as EXPIRY_D4_3_, organisati4_.NAME as NAME3_, organisati4_.CREATE_DATE as CREATE_D6_3_, organisati4_.CREATE_BY as CREATE_BY3_, organisati4_.MODIFY_DATE as MODIFY_D8_3_, organisati4_.MODIFY_BY as MODIFY_BY3_, organisati4_.PARTY_TYPE_FK as PARTY_T10_3_, orglevelim5_.ORGLEVELUID as ORGLEVEL1_4_, orglevelim5_.NAME as NAME4_, orglevelim5_.DESCRIPTION as DESCRIPT3_4_, orglevelim5_.LEVEL as LEVEL4_ from SERVOFF serviceoff0_ left outer join SERVOFFTYPE serviceoff1_ on serviceoff0_.SERVICE_OFFICER_TYPE_FK=serviceoff1_.UID left outer join USERORG userorgimp2_ on serviceoff0_.USER_ORG_FK=userorgimp2_.UID left outer join USERORGTYPE userorgtyp3_ on userorgimp2_.USER_ORG_TYPE_FK=userorgtyp3_.UID left outer join PARTY organisati4_ on userorgimp2_.ORGANISATION_FK=organisati4_.UID left outer join ORGLEVEL orglevelim5_ on userorgimp2_.ORG_LEVEL_FK=orglevelim5_.ORGLEVELUID where serviceoff0_.UID=?

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html

Here is my problem. I have a many to many relationship involving table CUstomer and table Officer.. the Officer table is that associated to another table called OfficerType (Salesman and serviceman).

I need to find customers who have a selected salesman and selected serviceman. I tried the following:
Code:
SELECT c FROM CustomerImpl AS c
JOIN FETCH c.serviceOfficers AS js
WHERE (js.uid IN ( :salesman )
AND js.uid IN ( :cso ) )

The result i get is no result. If i just select by salesman or cso only, i get the result. But quering both just won't do. Why?

I'm really stuck. Hope someone can help.


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.