Professional Documents
Culture Documents
Hibernate by Example: About The Speaker
Hibernate by Example: About The Speaker
Eitan Suez,
UptoData Inc
About the Speaker
Java Programmer
http://u2d.com/
eblog on http://!ava.net/
"#JS Speaker
$oal%
+ultiple Pro!ect%
+ultiple 'ay% to %et thi% up: a %ingle .ile, one .ile per
cla%%. 7e%t practice i% i% to u%e one .ile per cla%%,
'ith each .ile placed next to it% corre%ponding cla%%
.ile in the package hierarchy, and loaded a% a
re%ource
+apping
Entitie%
7a%ic Propertie%
1omponent%
A%%ociation%
+any-&o-)ne
)ne-&o-+any
+any-&o-+any
6nheritance +apping
Example mapping:
<many-to-one name="customer"
column="customer_id" />
the column %peci.ication re.erence% the
.oreign key in the invoice table
)ne-+any
/e.ault in hibernate v8
Example:
Example:
<bag name="actors" table="Movie_Actor">
<key column="movies_id"/>
<many-to-many column="actors_id"
class="com.u2d.movielib.Actor"/>
</bag>
6nheritance
#our Strategie%:
7a%ic :%age
Luerie%
1riteria AP6
7a%ic :%age
Primary &ype% are:
Se%%ion#actory
Se%%ion
Luery
1riteria
7a%ic :%age: Se%%ion#actory
ob!ect-oriented
1riteria AP6
Luery by Example
)ur code can %imply .etch the %e%%ion .rom the 'eb
%e%%ion or application context, and not 'orry about
having to clo%e the %e%%ion
Example:
Transaction tx = session.beginTransaction();
int i=0;
List<Widget> lotsOfWidgets = loadLotsOfWidgets();
for (Widget widget : lotsOfWidgets)
{
session.save(widget);
if ( ((i++) % 20) == 0)
{
s.flush();
s.clear();
}
}
session.getTransaction().commit();
<. :%er&ype
Ant &ool%
Eclip%e Plug-in%
+apping Editor
#ilter%
1on%i%t% o.:
http://'''.hibernate.org/
)i*e&nate A6ver%onB
1ontact 6n.ormation
Eitan SueI
http://u2d.com/
email: eitanQu2d.com