Forums Register Login

can we use hibernate when we need to create insert statement dynamically?....

+Pie Number of slices to send: Send
Hi
Thank you for reading my post
We have an application created using JDBC, for now application works but for next version we are planning to use a ORM framework as some parts of application is going to be re-writted .
now my question is :
in currect JDBC layer we have tens of dynamically created SQL statement (select / delete / update /insert) we build those statement based on user input and some other business logic.

my question is : Does hibernate support such thig ?
for example some times we select a query by joinin 3 tables when user need less details information and sometimes we should engage 5 tables.
can we do such tings with hibernate, or hibernate just allows us to have per table objects.

Thanks
+Pie Number of slices to send: Send
Hibernate do supports dynamic queries. You can Insert,delete,select and delete dynamically using Hibernate.

Hibernate uses JDBC as its core. So whatever possible in JDBC is also possible with Hibernate.

Good reference to Hibernate is:

http://www.hibernate.org/152.html

HTH,
+Pie Number of slices to send: Send
I understand where you are coming from.

You can always create an SQL Query object, and create your query string.

However, I think as you learn more about Hibernate, your current solutions will probalby change. When you talk about 3 or 5 tables being joined, the first thing that will be a "shock" to you is in regards to eager and lazy loading. You can only eager load one "many" table in such a join, as if you tried to have eager fetching with all 3-5 tables you would create a cartesian product, since Hibernate uses Left Outer Joins. So for those queries you will have to use SQLQuery and work with Object arrays, or "Select new MyObject(a, b, c)" to not have to work with object arrays, but with dynamically created queries you won't know how to create MyObject and its constructors since your query would be different each time.

Mark
You don't like waffles? Well, do you like this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 2538 times.
Similar Threads
Spring JDBC Vs Hibernate?
what if no ID column in the table for Hibernate?
oracle schema and instance
Prepared Statement
Hibernate - Slow Query on Entity Superclass
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 14:10:02.