| Author |
Message |
   
Abhysg
Side Hero Username: Abhysg
Post Number: 7054 Registered: 08-2008 Posted From: 68.39.93.169
Rating: N/A Votes: 0 (Vote!) | | Posted on Friday, October 05, 2012 - 06:21 am: |
    |
Cyberabadsinnodu:ee tag kuda unda...aithe chusta....btw HQL UNDI ANUKO EE CODE ekkada pettali...for ex: SELECT s.id, s.no from Stdent s this we can call HQL right ante aa id and no, Student pojo lo properties. then ee HQL code ni manam ee DAO nundi Hibernate call chestunnamo akkada pettukovacha?
annee okey soota ettuko... antha same code.. HQL ela calling sestavo SQL ni kooda alage sesko.. HQL/SQL ni oka single hbm file lo etteskoni.. namedqueries to sedugud adesko.. within db lo multiple schemas ku prob undadu.. schema name ni table mapping file lo define seskovachu.. selection ayite native sql lo rasko.. sukham ga untadi http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/qu erysql.html <sql-query> <return> SELECT person.NAME AS {person.name}, person.AGE AS {person.age}, person.SEX AS {person.sex} FROM PERSON person WHERE person.NAME LIKE :namePattern </sql-query> List people = sess.getNamedQuery("persons") .setString("namePattern", namePattern) .setMaxResults(50) .list(); no siggy |
   
Cyberabadsinnodu
Side Hero Username: Cyberabadsinnodu
Post Number: 4318 Registered: 02-2010 Posted From: 67.163.149.59
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, October 04, 2012 - 11:07 pm: |
    |
Dreamcatcher:
cool, will look at them tom..THanks nyways ఎంత చికాగో యునివర్సిటీ లో చదువుకున్నా చిలక్కొట్టుడికి సరైన ఇంగ్లీషు పదం దొరుకుతుందా..!! |
   
Dreamcatcher
Side Hero Username: Dreamcatcher
Post Number: 3407 Registered: 11-2009 Posted From: 71.114.100.237
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, October 04, 2012 - 11:04 pm: |
    |
Each table is mapped to a pojo. If you use annotations, you do not need hbm.xml files. Otherwise you will create a xml files and you list them in the hibernate configuration file. In your case, you will have three pojo classes, one for instructor, one for schedule, and one for student respectively mapped to their tables. Now, Instructor will have a reference to student and schedule. Hope that helps. http://www.developer.com/open/article.php/3559931/Hibernate- Basics.htm |
   
Cyberabadsinnodu
Side Hero Username: Cyberabadsinnodu
Post Number: 4317 Registered: 02-2010 Posted From: 67.163.149.59
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, October 04, 2012 - 11:04 pm: |
    |
Dreamcatcher:
btw thanks for the link from springsource, that helps in my work ఎంత చికాగో యునివర్సిటీ లో చదువుకున్నా చిలక్కొట్టుడికి సరైన ఇంగ్లీషు పదం దొరుకుతుందా..!! |
   
Cyberabadsinnodu
Side Hero Username: Cyberabadsinnodu
Post Number: 4316 Registered: 02-2010 Posted From: 67.163.149.59
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, October 04, 2012 - 11:03 pm: |
    |
Dreamcatcher:Your HQL/SQL goes into the DAO class where you are querying the database.
oka example padeyi annai...that is in a DAO file something, not plain HQL. plus Do we still need .hbm.xmls? for each pojo,I think YES. ఎంత చికాగో యునివర్సిటీ లో చదువుకున్నా చిలక్కొట్టుడికి సరైన ఇంగ్లీషు పదం దొరుకుతుందా..!! |
   
Dreamcatcher
Side Hero Username: Dreamcatcher
Post Number: 3404 Registered: 11-2009 Posted From: 71.114.100.237
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, October 04, 2012 - 10:59 pm: |
    |
Your HQL/SQL goes into the DAO class where you are querying the database. |
   
Cyberabadsinnodu
Side Hero Username: Cyberabadsinnodu
Post Number: 4315 Registered: 02-2010 Posted From: 67.163.149.59
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, October 04, 2012 - 10:57 pm: |
    |
Dreamcatcher:
lets forget abot schema..then how would we do? 1.create Instructor pojo and then inside there declare 2 additional pojos each for student, schedule? in .hbm.xml map those?? with properties? ఎంత చికాగో యునివర్సిటీ లో చదువుకున్నా చిలక్కొట్టుడికి సరైన ఇంగ్లీషు పదం దొరుకుతుందా..!! |
   
Dreamcatcher
Side Hero Username: Dreamcatcher
Post Number: 3403 Registered: 11-2009 Posted From: 71.114.100.237
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, October 04, 2012 - 10:57 pm: |
    |
Looks like there is a way using single datasource, but the trick is, you have to give schema1 user access to schema2 objects and then access schema2 objects through schema1 datasource...simillar problem and solution: http://forum.springsource.org/showthread.php?74932-Transacti on-across-schemas-in-a-database |
   
Cyberabadsinnodu
Side Hero Username: Cyberabadsinnodu
Post Number: 4314 Registered: 02-2010 Posted From: 67.163.149.59
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, October 04, 2012 - 10:56 pm: |
    |
Dreamcatcher:
also If i write HQL do i still need hbm.xml files for each pojo? ఎంత చికాగో యునివర్సిటీ లో చదువుకున్నా చిలక్కొట్టుడికి సరైన ఇంగ్లీషు పదం దొరుకుతుందా..!! |
   
Cyberabadsinnodu
Side Hero Username: Cyberabadsinnodu
Post Number: 4313 Registered: 02-2010 Posted From: 67.163.149.59
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, October 04, 2012 - 10:55 pm: |
    |
Dreamcatcher:
Here we need two datasources in weblogic, and spring annotation XML file.can we use two schemas at a time? ofcourse 1 pull data from major table, 2nd and then another from 3 rd table. one more question if I use HQL where the query goes? is it in the class where we r querying? for ex: if I am queryin from DAO, then I can write HQL and get result lsit? ఎంత చికాగో యునివర్సిటీ లో చదువుకున్నా చిలక్కొట్టుడికి సరైన ఇంగ్లీషు పదం దొరుకుతుందా..!! |
   
Dreamcatcher
Side Hero Username: Dreamcatcher
Post Number: 3402 Registered: 11-2009 Posted From: 71.114.100.237
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, October 04, 2012 - 10:49 pm: |
    |
Tammudu, Your question is not clear to me. I am assuming you have two datasources, one for each schema. You can build a criteria using one datasource, which will be talking to one schema. so, this criteria cannot interact with another schema. This is my understanding. I think your approach should be to retrieve data you need from one schema that has pivot table, then use that data to pull related data from second schema. Hope that helps. Here is a similar question and response: http://stackoverflow.com/questions/3552330/doing-a-join-over -2-tables-in-different-databases-using-hibernate |
   
Cyberabadsinnodu
Side Hero Username: Cyberabadsinnodu
Post Number: 4312 Registered: 02-2010 Posted From: 67.163.149.59
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, October 04, 2012 - 10:16 pm: |
    |
Abhysg:<sql-query> lo toseyyi
ee tag kuda unda...aithe chusta....btw HQL UNDI ANUKO EE CODE ekkada pettali...for ex: SELECT s.id, s.no from Stdent s this we can call HQL right ante aa id and no, Student pojo lo properties. then ee HQL code ni manam ee DAO nundi Hibernate call chestunnamo akkada pettukovacha? ఎంత చికాగో యునివర్సిటీ లో చదువుకున్నా చిలక్కొట్టుడికి సరైన ఇంగ్లీషు పదం దొరుకుతుందా..!! |
   
Abhysg
Side Hero Username: Abhysg
Post Number: 7051 Registered: 08-2008 Posted From: 68.39.93.169
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, October 04, 2012 - 10:02 pm: |
    |
SQL voste.. <sql-query> lo toseyyi... return type ki nee own model defin sesi ivvu.. very simple.. hibernate ni vichalavidi ga vadeskovachu.. no siggy |
   
Cyberabadsinnodu
Side Hero Username: Cyberabadsinnodu
Post Number: 4310 Registered: 02-2010 Posted From: 67.163.149.59
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, October 04, 2012 - 08:46 pm: |
    |
Npa:
thanks bro for inputs ఎంత చికాగో యునివర్సిటీ లో చదువుకున్నా చిలక్కొట్టుడికి సరైన ఇంగ్లీషు పదం దొరుకుతుందా..!! |
   
Cyberabadsinnodu
Side Hero Username: Cyberabadsinnodu
Post Number: 4309 Registered: 02-2010 Posted From: 67.163.149.59
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, October 04, 2012 - 08:46 pm: |
    |
Npa:tack overflow lo post eyyandi
k will do it ఎంత చికాగో యునివర్సిటీ లో చదువుకున్నా చిలక్కొట్టుడికి సరైన ఇంగ్లీషు పదం దొరుకుతుందా..!! |
   
Npa
Hero Username: Npa
Post Number: 10684 Registered: 05-2007 Posted From: 98.193.224.83
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, October 04, 2012 - 08:41 pm: |
    |
Cyberabadsinnodu: but composite keys tho etina prob untada in .hbm.xml files for all pojos? akkada kuda composite-keys ani oka attrib undi...but only 1 key ee work avutundi..
comp. keys no idea...my suggestion..ida time bokka annai..stack overflow lo post eyyandi Hmmm.... |
   
Npa
Hero Username: Npa
Post Number: 10683 Registered: 05-2007 Posted From: 98.193.224.83
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, October 04, 2012 - 08:40 pm: |
    |
Cyberabadsinnodu:
basic ga hibernate configuration either hbm files dwara cheyotchu leda annotations vaadi chyotchu....hbm files vaadi chesthe...hbm files lo one to one mapping cheyyali...and pojo lo kuda second pojo reference first pojo lo undali.... Hmmm.... |
   
Cyberabadsinnodu
Side Hero Username: Cyberabadsinnodu
Post Number: 4308 Registered: 02-2010 Posted From: 67.163.149.59
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, October 04, 2012 - 08:35 pm: |
    |
Npa:
i know that, but composite keys tho etina prob untada in .hbm.xml files for all pojos? akkada kuda composite-keys ani oka attrib undi...but only 1 key ee work avutundi.. ఎంత చికాగో యునివర్సిటీ లో చదువుకున్నా చిలక్కొట్టుడికి సరైన ఇంగ్లీషు పదం దొరుకుతుందా..!! |
   
Cyberabadsinnodu
Side Hero Username: Cyberabadsinnodu
Post Number: 4307 Registered: 02-2010 Posted From: 67.163.149.59
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, October 04, 2012 - 08:33 pm: |
    |
Npa:
ok ikkada naaku kavalsindi...manamu first Instructor pojo rasi, dantlo student, schedule obj declare seyala? assume Instructor is main table. and how about hbm.xml files for all of those pojos, also hbm-config.xml? ఎంత చికాగో యునివర్సిటీ లో చదువుకున్నా చిలక్కొట్టుడికి సరైన ఇంగ్లీషు పదం దొరుకుతుందా..!! |
   
Npa
Hero Username: Npa
Post Number: 10681 Registered: 05-2007 Posted From: 98.193.224.83
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, October 04, 2012 - 08:30 pm: |
    |
Cyberabadsinnodu:sample examples ok annai kani danni mana complexity ki marchude kattam ga undi..
neeku tagatee itcha...chudu... lets make it simple...neeku criteria concept vadi join ela cheyalo telisthe saripoddi....migitha joins ki extend chesukovatchu...konchem google...set..leda nenu itchina example konchem keen ga chudu..telsipoddi Hmmm.... |
   
Cyberabadsinnodu
Side Hero Username: Cyberabadsinnodu
Post Number: 4306 Registered: 02-2010 Posted From: 67.163.149.59
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, October 04, 2012 - 08:27 pm: |
    |
Npa:
sample examples ok annai kani danni mana complexity ki marchude kattam ga undi.. ఎంత చికాగో యునివర్సిటీ లో చదువుకున్నా చిలక్కొట్టుడికి సరైన ఇంగ్లీషు పదం దొరుకుతుందా..!! |
   
Npa
Hero Username: Npa
Post Number: 10678 Registered: 05-2007 Posted From: 98.193.224.83
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, October 04, 2012 - 08:26 pm: |
    |
I would try this in Instructor's data access layer....mess around with this..rough ga itcha...inka kochens unte stack overflow lo post eyyandi..within 1 hr lo vasthadi answer working hrs lo ayithe... Criteria crit = getSession().createCriteria(getPersitentClass()) .add(Restrictions.eq("deptno",deptno)) .setFetchMode("student",FetchMode.JOIN) .createCriteria("student") .createCriteria("schedule") then where u want results say, crit.list() Hmmm.... |
   
Blackmamba
Moderator Username: Blackmamba
Post Number: 21317 Registered: 05-2010
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, October 04, 2012 - 08:19 pm: |
    |
Npa:
 |
   
Npa
Hero Username: Npa
Post Number: 10677 Registered: 05-2007 Posted From: 98.193.224.83
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, October 04, 2012 - 08:17 pm: |
    |
Cyberabadsinnodu:adhi DBA rasi ichinadu...problem enti ante we shud not use plain sql, have to use hibernate like createCriteria etc
yes....criteria ane concept undadi hibernate lo...adi vadatam best...hold on...i will give you a sample query in next post...try it...might work Hmmm.... |
   
Cyberabadsinnodu
Side Hero Username: Cyberabadsinnodu
Post Number: 4305 Registered: 02-2010 Posted From: 67.163.149.59
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, October 04, 2012 - 08:16 pm: |
    |
Npa:adhi hibernate build chesina query aa meeru raasina query aa?..
adhi DBA rasi ichinadu...problem enti ante we shud not use plain sql, have to use hibernate like createCriteria etc ఎంత చికాగో యునివర్సిటీ లో చదువుకున్నా చిలక్కొట్టుడికి సరైన ఇంగ్లీషు పదం దొరుకుతుందా..!! |
   
Npa
Hero Username: Npa
Post Number: 10675 Registered: 05-2007 Posted From: 98.193.224.83
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, October 04, 2012 - 08:05 pm: |
    |
Cyberabadsinnodu:
adhi hibernate build chesina query aa meeru raasina query aa?... meeru raasina query ayithe inka why hibernate using? Hmmm.... |
   
Cyberabadsinnodu
Side Hero Username: Cyberabadsinnodu
Post Number: 4304 Registered: 02-2010 Posted From: 67.163.149.59
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, October 04, 2012 - 08:03 pm: |
    |
Npa:select lo tables itcharendi?..colums ivvali kada...
adhi table object I anedi table obj nothing but a table...so i.colName will work ఎంత చికాగో యునివర్సిటీ లో చదువుకున్నా చిలక్కొట్టుడికి సరైన ఇంగ్లీషు పదం దొరుకుతుందా..!! |
   
Npa
Hero Username: Npa
Post Number: 10672 Registered: 05-2007 Posted From: 98.193.224.83
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, October 04, 2012 - 07:56 pm: |
    |
Cyberabadsinnodu:
select lo tables itcharendi?..colums ivvali kada...try this SELECT * FROM Schema1.Instructor I, Schema1.student s, schema2.Schedule sc WHERE I.Id=s.Id and I.code = s.code and I.className = Sc.className and I.DeptNo = ? PS- yee forum lo hibernate kochen adigithe evad septhad annai....stackOverflow ani untadi...dantlo eyyandi cheptha....i get brilliant answers for some of my tough kochens.. Hmmm.... |
   
Cyberabadsinnodu
Side Hero Username: Cyberabadsinnodu
Post Number: 4303 Registered: 02-2010 Posted From: 67.163.149.59
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, October 04, 2012 - 07:52 pm: |
    |
Npa:light ga telsu...kochen adagandi...telisthe septhan
Hi I am new to Hibernate, but have JPA exp. Here is the thing I need to do. I have 3 tables called Instructor, student, Schedule. Instructor, student are on same schema say Schema1. Schedule is another schema, Schema2. Instructor has 4 COMPOSITE KEYS(PKs). same as with student and schedhule. here is sql Here I am just giviing the columns that I want to join but there are many also some of the remaining are composite keys) SELECT Schema1.Instructor I, Schema1.student s, schema2.Schedule sc WHERE I.Id=s.Id and I.code = s.code and I.className = Sc.className (all are one-one mapping) and I.DeptNo = ? (means we are passing) ఎంత చికాగో యునివర్సిటీ లో చదువుకున్నా చిలక్కొట్టుడికి సరైన ఇంగ్లీషు పదం దొరుకుతుందా..!! |
   
Npa
Hero Username: Npa
Post Number: 10670 Registered: 05-2007 Posted From: 98.193.224.83
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, October 04, 2012 - 07:50 pm: |
    |
light ga telsu...kochen adagandi...telisthe septhan Hmmm.... |
   
Gandhiguevara
Legend Username: Gandhiguevara
Post Number: 34446 Registered: 10-2009 Posted From: 98.197.251.182
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, October 04, 2012 - 07:48 pm: |
    |
Cyberabadsinnodu:elle he..i am asking hibernate framework
mari clear gaa adagaali |
   
Cyberabadsinnodu
Side Hero Username: Cyberabadsinnodu
Post Number: 4302 Registered: 02-2010 Posted From: 67.163.149.59
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, October 04, 2012 - 07:47 pm: |
    |
Gandhiguevara:winter lo aithe bears and some other animal hibernate avuthaayi
elle he..i am asking hibernate framework ఎంత చికాగో యునివర్సిటీ లో చదువుకున్నా చిలక్కొట్టుడికి సరైన ఇంగ్లీషు పదం దొరుకుతుందా..!! |
   
Gandhiguevara
Legend Username: Gandhiguevara
Post Number: 34444 Registered: 10-2009 Posted From: 98.197.251.182
Rating:  Votes: 1 (Vote!) | | Posted on Thursday, October 04, 2012 - 07:46 pm: |
    |
winter lo aithe bears and some other animal hibernate avuthaayi |
   
Cyberabadsinnodu
Side Hero Username: Cyberabadsinnodu
Post Number: 4300 Registered: 02-2010 Posted From: 67.163.149.59
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, October 04, 2012 - 07:45 pm: |
    |
pls reply... ఎంత చికాగో యునివర్సిటీ లో చదువుకున్నా చిలక్కొట్టుడికి సరైన ఇంగ్లీషు పదం దొరుకుతుందా..!! |