avatar
Hibernate question# Java - 爪哇娇娃
c*t
1
Does hibernate provide database server solutions that improves
the retrieval of data objects?
For example, instead of making multiple SQL queries to retrieve
the data and its children, do one query and through the use of
server solution to package the result and decript the data on
the client, to improve the performance.
I am trying to do some research to see if there anything interesting
could be done in this area.
avatar
F*n
2
It does use some query processing techniques but normally not the most
interesting ones. Commercially oriented products normally only use "mature"
technologies (not newest in academic sense) and if I really want to study DB
query optimization I would go to read the latest papers.

【在 c*****t 的大作中提到】
: Does hibernate provide database server solutions that improves
: the retrieval of data objects?
: For example, instead of making multiple SQL queries to retrieve
: the data and its children, do one query and through the use of
: server solution to package the result and decript the data on
: the client, to improve the performance.
: I am trying to do some research to see if there anything interesting
: could be done in this area.

avatar
c*t
3
No. You misunderstood what I was asking.
The issue at hand is not query optimization. But how to fetch
data efficiently. For instance, outer join let you retrieve
parent and child (assuming 1-1) in one single select statement.
However, if there are multiple children of the same type (1-many),
then such selection may not be efficient. Without outer join,
other approaches (without server component) would require multiple
selection statements.
This is a known issue for ORM tools. However, I ch

【在 F****n 的大作中提到】
: It does use some query processing techniques but normally not the most
: interesting ones. Commercially oriented products normally only use "mature"
: technologies (not newest in academic sense) and if I really want to study DB
: query optimization I would go to read the latest papers.

avatar
F*n
4
I guess at the level of hibernate (or other Java ORM tools), you have to
either use table join or multiple select statements because you have no
control over the underlying DB.
However, you can set fetch type in hibernate, for example "eager fetch"
would probably use on select with join and "lazy fetch" will create the
object for now and use another select to fetch the data when necessary.

【在 c*****t 的大作中提到】
: No. You misunderstood what I was asking.
: The issue at hand is not query optimization. But how to fetch
: data efficiently. For instance, outer join let you retrieve
: parent and child (assuming 1-1) in one single select statement.
: However, if there are multiple children of the same type (1-many),
: then such selection may not be efficient. Without outer join,
: other approaches (without server component) would require multiple
: selection statements.
: This is a known issue for ORM tools. However, I ch

avatar
g*g
5
Not sure what exactly you are looking, hql allow you to
do outer join. Lazy fetching can avoid many unneccesary
retrieval. And secondary caching may help performance.

【在 c*****t 的大作中提到】
: No. You misunderstood what I was asking.
: The issue at hand is not query optimization. But how to fetch
: data efficiently. For instance, outer join let you retrieve
: parent and child (assuming 1-1) in one single select statement.
: However, if there are multiple children of the same type (1-many),
: then such selection may not be efficient. Without outer join,
: other approaches (without server component) would require multiple
: selection statements.
: This is a known issue for ORM tools. However, I ch

avatar
t*e
6
What OP described is also known as n+1 select problem. The solution is to
run eager fetching. From "extra lazy" to eager, there are 7 levels a
developer can choose from. An appropriate fetching level will lead you to
optimized query performance. Besides, another great feature of Hibernate is
auto dirty checking that prevents unnecessary update operations.
avatar
m*t
7

I think fetch and laziness are controlled by two separate attributes,
namely 'fetch' and 'lazy'.
fetch="join" is probably what OP wants.

【在 F****n 的大作中提到】
: I guess at the level of hibernate (or other Java ORM tools), you have to
: either use table join or multiple select statements because you have no
: control over the underlying DB.
: However, you can set fetch type in hibernate, for example "eager fetch"
: would probably use on select with join and "lazy fetch" will create the
: object for now and use another select to fetch the data when necessary.

avatar
c*t
8
I don't care about the laziness. What I care is when the parent/children
needs to be retrieved, whether or not Hibernate can quickly retrieve all
of them at once.
For example, query Person and past work places (many-many), I'd like to
retrieve all of them at once using a single select query, rather than
using separated SQL statements.
I think that it is possible by adding a simple databaser server extension
(and hence the question in the original post), so it is likely someone
has thought about

【在 m******t 的大作中提到】
:
: I think fetch and laziness are controlled by two separate attributes,
: namely 'fetch' and 'lazy'.
: fetch="join" is probably what OP wants.

avatar
t*e
9
inner join, outer join是一对
eager fetch, lazy fetch是一对,
可以组合成 eager inner, eager outer, lazy inner, lazy outer.

【在 m******t 的大作中提到】
:
: I think fetch and laziness are controlled by two separate attributes,
: namely 'fetch' and 'lazy'.
: fetch="join" is probably what OP wants.

avatar
m*t
10

Did you try fetch="join" on the association mapping? (in this case
the mapping for PastWorkPlaces)

【在 c*****t 的大作中提到】
: I don't care about the laziness. What I care is when the parent/children
: needs to be retrieved, whether or not Hibernate can quickly retrieve all
: of them at once.
: For example, query Person and past work places (many-many), I'd like to
: retrieve all of them at once using a single select query, rather than
: using separated SQL statements.
: I think that it is possible by adding a simple databaser server extension
: (and hence the question in the original post), so it is likely someone
: has thought about

avatar
b*y
11
我来说说想法。没有用过hibernate, 但觉得还是写raw sql带劲儿。不过,hibernate
的好处就是可以任意转换数据库。
avatar
s*e
12
Hibernate does provide 'bulk' retrieval with join. in such case, it will
allow you to retrieve, for example, 10 people and their past work places
with one single db hit. But you should bear in mind, that no ORM is designed
for bulk operation, so you should to try to not use this feature. If it is
absolutely needed, you should always limit the number of records you want to
retrieve for one db visit, for example, you want to return only 9 other
persons if you want to get information about smectite
avatar
F*n
13
I think it can only be done with some DBMS extension. However, before you do
that, you should realize this is NOT new stuffs. OODBMS has handled that a
long time ago. It's a shame that fat cats in big companies turned down
OODBMS, and that's the reason today we need those stupid ORM stuffs.

【在 c*****t 的大作中提到】
: I don't care about the laziness. What I care is when the parent/children
: needs to be retrieved, whether or not Hibernate can quickly retrieve all
: of them at once.
: For example, query Person and past work places (many-many), I'd like to
: retrieve all of them at once using a single select query, rather than
: using separated SQL statements.
: I think that it is possible by adding a simple databaser server extension
: (and hence the question in the original post), so it is likely someone
: has thought about

avatar
s*e
14
You can define a database view for the outer join and then use Hibernate to
interface with the view.

【在 c*****t 的大作中提到】
: Does hibernate provide database server solutions that improves
: the retrieval of data objects?
: For example, instead of making multiple SQL queries to retrieve
: the data and its children, do one query and through the use of
: server solution to package the result and decript the data on
: the client, to improve the performance.
: I am trying to do some research to see if there anything interesting
: could be done in this area.

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。