hibernate onjava notes#many-to-one

Q: biz logic implemented where?
A: beans representing db entities.

Q: explain the many-to-one:
<class name="test.hibernate.OrderItem"
table=”order_items”>
<many-to-one name="order"
class=”test.hibernate.Order”
column=”order_id” />
<many-to-one name="product"

A: first many-to-one means many of this (OrderItem) linked to one
order. ANY link like this requires a link-column/join-column, which is
“order_items.order_id”

what makes a class abstract

If compiler detects an abstract method, the (“host”) class must be declared abstract.

I think this is the only difference between abstract class and non-abstract class.

U can convert a non-abstract class into abstract by adding the keyword “abstract” to the class. All attributes are left alone. Yes, an abstract class can CONTAIN instance-level fields as well as static (ie class-level) members.

(un)correlated subquery^join

Correlated/uncorrelated sub-queries and joins are blood brothers and often simultaneously usable to solve a given problem. A few non-obvious differences.

* subquery — clearer than joins
sub query may look unfriendly compared to joins, but actually the logic is easier to make out.

* uncorrelated — most readable
Uncorrelated is usually *simpler* than joins or correlated.

* uncorrelated — fast
b’cos one nested scan only. Correlated (not uncorrelated) can hurt performance because it could involve one scan per value “passed in”

Uncorrelated requires just one execution of the sub query.