-->
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.  [ 10 posts ] 
Author Message
 Post subject: Complete persistence layer independence
PostPosted: Mon Mar 29, 2010 5:07 am 
Newbie

Joined: Thu Mar 25, 2010 4:26 am
Posts: 7
Hi,

We need to migrate our persistence layer code written in pure jdbc call to Hibernate.
We are facing below mentioned issues in migrating the same.

1) For Insert ,update ,delete operation ,since our object model and DB Model are in sync we are able to sucessfully port the code to HQL.

2) For select and select List operation ,the object model and database model are completely out of sync and therefore implemention while converting it to HQL we faced below mentioned issues.

2.1) Since the Object and tables are unrelated we were not able to implement joins(Outer Joins)

Theerfore with reference to above mentioned issues what will be the best possible alternatives.

Regards
Rajeev


Top
 Profile  
 
 Post subject: Re: Complete persistence layer independence
PostPosted: Mon Mar 29, 2010 6:18 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Quote:
1) For Insert ,update ,delete operation ,since our object model and DB Model are in sync we are able to sucessfully port the code to HQL.


Do you meant: for insert ,update ,delete operation you are able to sucessfully port the code to Hibernate.
Or do you really explicitly call HQL (Hiberante-Query-Language) queries in order to realize inserts, updates and delete operations ?
(Latter would be a very unusual approach to use Hibernate).


Top
 Profile  
 
 Post subject: Re: Complete persistence layer independence
PostPosted: Mon Mar 29, 2010 7:47 am 
Newbie

Joined: Thu Mar 25, 2010 4:26 am
Posts: 7
Hi,

yes we are sucessfully able to port insert update and delete queries.
but we are not able to port select statement due to the problem mentioned
above.

Regards
Rajeev Kumar Pandey


Top
 Profile  
 
 Post subject: Re: Complete persistence layer independence
PostPosted: Mon Mar 29, 2010 8:29 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Hi,

apparently you did not understand what I intended to ask.
Do you use session.save(newobject) or entityManager.persist(newobject) in order to do new inserts,
or do you something like session.createQuery("....").executeUpdate() ?


Top
 Profile  
 
 Post subject: Re: Complete persistence layer independence
PostPosted: Mon Mar 29, 2010 8:45 am 
Newbie

Joined: Thu Mar 25, 2010 4:26 am
Posts: 7
Hi,

I am using session.save(Object obj) and session.update(Object obj) for my insert and update opertaion.

Regards
Rajeev


Top
 Profile  
 
 Post subject: Re: Complete persistence layer independence
PostPosted: Mon Mar 29, 2010 9:48 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Quote:
I am using session.save(Object obj) and session.update(Object obj) for my insert and update opertaion.


OK, that's good.

What do you mean indeed with
Quote:
Since the Object and tables are unrelated


Do you have no relations (fields which acts as foreign keys) between your tables?
What is 'the Object' ?


Top
 Profile  
 
 Post subject: Re: Complete persistence layer independence
PostPosted: Mon Mar 29, 2010 10:01 am 
Newbie

Joined: Thu Mar 25, 2010 4:26 am
Posts: 7
Hi,

For select and selectList operation we are using right outer join query specific to oracle and our table do not have any association based on foreign keys.

From Object i mean my domain Model.

we are fetching the data from multiple table using oracle sql query and using a seperate pojo to populate the fecthed results.

Regards
Rajeev


Top
 Profile  
 
 Post subject: Re: Complete persistence layer independence
PostPosted: Mon Mar 29, 2010 10:43 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Quote:
our table do not have any association based on foreign keys.


So on what are your associations based, if not on foreign keys ?
Can you show some concrete example?

By the way,
in Hibernate you can also use session.createSQLQuery(String sql) which accepts queries in SQL-syntax,
so there you could place the join-queries you usually used with plain jdbc.


Top
 Profile  
 
 Post subject: Re: Complete persistence layer independence
PostPosted: Tue Mar 30, 2010 12:40 am 
Newbie

Joined: Thu Mar 25, 2010 4:26 am
Posts: 7
Hi,

As mentioned earlier there is no association between the tables and we are fetching the data using
theta style joins.

To your suggestion regarding using createSQLQuery(String sql) the sql will be oracle specific and we will not be able to achieve the complete db independence.

Some one susggest that converting all our oracle specific sql statement to ANSI sql which is supported by multiple DB's.
Please suggest.

Regards
Rajeev


Top
 Profile  
 
 Post subject: Re: Complete persistence layer independence
PostPosted: Wed Mar 31, 2010 6:35 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Can you show some example of concrete theta style joins?
Usually joins are made over foreign keys, so I wondering what you are joining.
(For me a foreign key must not mandatory have a constraint defined on it.
As soon a field refers to a primary key of another table, it is a foreign key logically seen).


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 

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.