Sunday, August 17, 2008

Hibernate First Impression

Now, lets talk about object persistence framework. It is Hibernate. How to generate tables in database from POJOs (Plain Old Java Objects). All that you need are:
1. Eclipse as IDE
2. MySQL 5 as Database
We also need other libraries such as:
1. Hibernate-3.*
2. MySQL-connector-java-5.*
3. Jakarta-commons
4. X-Doclet-1.*

To generate tables in database from POJOs with hibernate, we need mapping files (*.hbm.xml) for that POJOs. As example, User.java (a POJO) need User.hbm.xml that will be used to map that POJO with table in database. We also need a hibernate configuration file (hibernate.cfg.xml). It is needed to configure database properties with hibernate. In this example we will generate both of *.hbm.xml and hibernate.cfg.xml by using X-Doclet and Ant. Let's start it.

Firstly create database named ndung in MySQL.


Create a java project in Eclipse named HibernateExample. Create a new folder named lib. It is used to place our libraries. Move all libraries above to folder lib. So in the lib folder, there are 4 folders inside. Also add a properties file in the lib folder named lib.properties. This is an example, my lib.properties. It show my libraries configuration. Make it in your own. Also configure build path our project into these libraries.

lib.properties

In source folder make java package named com.ndung.model and com.ndung.main. We will place our POJOs in com.ndung.model and main file in com.ndung.main. Create java classes in com.ndung.model named User.java and HibernateUtil.java. In other side, create java class named Main.java in com.ndung.main.

User.java


HibernateUtil.java


Main.java

Now, we will generate User.hbm.xml and hibernate.cfg.xml automatically by using X-Doclet and Ant. Make two xml files in the project named properties.xml and build.xml.

properties.xml


build.xml

To run Ant based on our own build.xml file, in Eclipse menu bar click Window, click Show View menu item, and click Ant menu item. Ant panel will show up in the right of Eclipse. Right click on that panel, click Add Buildfiles. Choose build.xml to add from HibernateExample project. 4 menus will show up in that panel below HibernateExample. Double click on hibernatedoclet. It will generate hibernate mapping files and also a hibernate configuration file. Check out in source folder, there are 2 new xml files. They are User.hbm.xml in /com/ndung/model folder and hibernate.cfg.xml.

User.hbm.xml


hibernate.cfg.xml

Then double click on run in Ant panel. Now, check out your database.


Btw, Long Live My Indonesia...

257 comments:

1 – 200 of 257   Newer›   Newest»
Adam Flater said...

Would you mind posting the source files for this example?

thanks

Anonymous said...

@Adam
Sorry, Now, i haven't time to upload source code. Maybe... Next Time...

Anonymous said...

where to buy ambien online generic name for ambien - side effects of generic ambien

Anonymous said...

xanax generic xanax pictures of pills - xanax and alcohol consumption

Anonymous said...

can you sniff diazepam diazepam zopiclone together - diazepam regime alcohol withdrawal

Anonymous said...

buy alprazolam online no prescription xanax 2mg dosage - xanax side effects upset stomach

Anonymous said...

xanax antidepressant does 1mg xanax look like - xanax .25 to get high

Anonymous said...

diazepam 10 mg diazepam 5mg spc - diazepam yahoo answers

Anonymous said...

xanax generic xanax side effects hiccups - buy xanax no prescription mastercard

Anonymous said...

diazepam online diazepam tablets 5mg - diazepam narcotic withdrawal

Anonymous said...

phentermine online buy phentermine 37.5 online no prescription - phentermine without rx

Anonymous said...

buy diazepam online diazepam side effects humans - generic brand for valium

Anonymous said...

phentermine online how to buy phentermine online no prescription - buy phentermine uk online

Anonymous said...

ambien medication ways get high ambien - ambien cr manufacturer coupon

Anonymous said...

buy generic phentermine phentermine online prescription - buy generic phentermine no prescription

Anonymous said...

ambien price ambien side effects long term use - ambien side effects mood

Anonymous said...

buy xanax without prescriptions xanax 60 minutes - xanax overdose wiki

Anonymous said...

buy ambien online no prescription buy ambien france - ambien medication for sleep

Anonymous said...

discount xanax xanax movie quotes - will 2mg xanax do anything

Anonymous said...

diazepam contraindications que es mas fuerte diazepam o clonazepam - buy diazepam valium

Anonymous said...

xanax 0.5mg xanax g3721 - buy xanax online europe

Anonymous said...

what is diazepam used for buy diazepam online no rx - generic diazepam images

Anonymous said...

buy generic phentermine buy phentermine online mexico - phentermine online+yahoo

Anonymous said...

buy diazepam diazepam dosage range - diazepam dosage by weight

Anonymous said...

order phentermine online buy phentermine online without tx - phentermine online order

Anonymous said...

generic zolpidem ambien side effects mayo clinic - ambien and breastfeeding

Anonymous said...

phentermine without prescription buy phentermine hcl 37.5 no prescription - phentermine forum 2012

Anonymous said...

buy ambien ambien miracle drug - ambien side effects the next day

Anonymous said...

carisoprodol 350 mg buy hgh - somatropin pills - buy somatropin pills

Anonymous said...

xanax for sale without prescription order xanax internet - xanax online order

Anonymous said...

order ambien online ambien side effects pregnancy - ambien cr 7 night free trial

Anonymous said...

buy xanax online overnight 1mg klonopin equal xanax - xanax 1mg image

Anonymous said...

buy alprazolam xanax pills information - xanax side effects last long

Anonymous said...

diazepam online cheap diazepam no prescription - diazepam 10mg prices

Anonymous said...

no prescription xanax xanax junkie - xanax overdose 1mg

Anonymous said...

diazepam diazepam uses - buy diazepam usa no prescription

Anonymous said...

order phentermine phentermine online paypal - buy phentermine in mexico

Anonymous said...

diazepam diazepam dose half-life - buy valium online paypal

Anonymous said...

ambien 5 ambien high blood pressure meds - ambien zolpidem tartrate 10 mg

Anonymous said...

buy phentermine buy real phentermine online - phentermine results in 1 month

Anonymous said...

ambien cr use ambien insomnia - ambien overdose child

Anonymous said...

ambien pills ambien cr 12.5 cost - ambien side effects liver

Anonymous said...

buy xanax online no prescription cheap how long does a xanax high last - 4 xanax overdose

Anonymous said...

buy tramadol online with mastercard tramadol online without rx - but tramadol online uk

Anonymous said...

soma online carisoprodol recreational - jugar cubo soma online

Anonymous said...

mixing diazepam and lorazepam valium diazepam que es - safe buy diazepam online usa

Anonymous said...

is it illegal to buy xanax online how much xanax and alcohol does it take to overdose - xanax side effects violent

Anonymous said...

buy ambien online without prescription ambien 73 93 - ambien side effects fatigue

Anonymous said...

can you sniff diazepam diaze 10 mg diazepam - diazepam (valium) synthesis

Anonymous said...

buy tramadol online buy tramadol online 100mg - tramadol hcl dosage humans

Anonymous said...

buy soma online somamedication.net - soma drug opiate

Anonymous said...

diazepam without prescription buy cheap diazepam online no prescription - diazepam usual dosage

Anonymous said...

cheap tramadol online tramadol 0 1g - buy tramadol in the uk

Anonymous said...

buy diazepam online diazepam 2 mg dzialanie - buy valium online no prescription

Anonymous said...

order tramadol online cod tramadol hcl mechanism of action - tramadol hcl and pregnancy

Anonymous said...

xanax for sale without prescription buy cheap xanax online no prescription - cheap xanax online no prescription

Anonymous said...

xanax without prescription can you take 2 mg xanax at once - xanax insomnia

Anonymous said...

buy tramadol medication tramadol 200mg high - buy ultram online with no prescription

Anonymous said...

intravenous diazepam diazepam 2mg asthma - diazepam 10mg for cats

Anonymous said...

alprazolam 0.5mg buy xanax from pakistan - metronidazole and xanax drug interactions

Anonymous said...

buy soma online soma drug test benzo - carisoprodol much get high

Anonymous said...

diazepam contraindications where to buy diazepam in the usa - diazepam 5mg anxiety

Anonymous said...

buy ambien online without prescription ambien dosage cr - generic name of ambien cr

Anonymous said...

buy tramadol hcl buy ultram online canada - tramadol 50 mg walmart

Anonymous said...

generic soma online somanabolic muscle maximizer legit - carisoprodol normal dose

Anonymous said...

buy cheap diazepam can you buy diazepam online - hk 10 mg diazepam

Anonymous said...

ambien on line buy real ambien online - cost of ambien cr 12.5 mg

Anonymous said...

buy tramadol cash on delivery tramadol for dogs dosage uk - tramadol hcl odt

Anonymous said...

purchase xanax xanax depression - best place to buy xanax online forum

Anonymous said...

soma online what drug category is soma - soma medication overnight

Anonymous said...

buy diazepam generic valium diazepam dosage equivalent clonazepam - diazepam highly addictive

Anonymous said...

buy ambien online ambien sound generator - buy ambien cr usa

Anonymous said...

buy tramadol overnight order tramadol american express - tramadol online reviews

Anonymous said...

order tramadol online mastercard tramadol 50mg recommended dosage - tramadol grasscity

Anonymous said...

buy tramadol no rx buy tramadol online missouri - tramadol dosage sr

Anonymous said...

order xanax xanax dose get high - xanax xr 1mg high

Anonymous said...

tramadol online tramadol 4 men - buy tramadol uk pharmacy

Anonymous said...

buy tramadol online tramadol hcl hcl - tramadol an 627 online

Anonymous said...

buy xanax buy xanax online in the uk - buy xanax online no rx

Anonymous said...

order tramadol tramadol yellow - tramadol hcl er 300

Anonymous said...

diazepam generics buy genuine diazepam online - diazepam indications

Anonymous said...

buy xanax without prescriptions xanax generic identification - smoking xanax high

Anonymous said...

buy tramadol tramadol dosage guide - tramadol hcl online

Anonymous said...

diazepam diazepam low dosage - diazepam dosage in elderly

Anonymous said...

buy tramadol cash on delivery tramadol dosage for humans - tramadol online with no prescription

Anonymous said...

ambien ambien 20mg - purchase generic ambien

Anonymous said...

buy tramadol online european online pharmacy tramadol - tramadol 50mg

Anonymous said...

soma online soma urine drug screen - buy soma online with cod

Anonymous said...

diazepam no prescription needed valium diazepam que es - buy diazepam mexico

Anonymous said...

where can i buy ambien online ambien rage - zolpidem er good ambien cr

Anonymous said...

buy tramadol with cod buy tramadol from canada - tramadol hcl pregnancy

Anonymous said...

soma online generic soma capsules - generic soma pill identification

Anonymous said...

ambien drug drug interactions propranolol ambien - ambien snorting

Anonymous said...

buy xanax online xanax bars colors - xanax side effects yahoo answers

Anonymous said...

buy soma online carisoprodol 700 mg - buy somatropin hgh

Anonymous said...

order tramadol online buy tramadol generic ultram - tramadol hcl 627

Anonymous said...

tramadol online overnight tramadol high drugs - tramadol opiate

Anonymous said...

buy tramadol online mastercard overnight cheapest ultra online - order tramadol

Anonymous said...

buy tramadol overnight cod tramadol high liver enzymes - tramadol 50mg pain killer

Anonymous said...

cheap tramadol tramadol 50 mg price street - tramadol tolerance

Anonymous said...

buy tramadol online tramadol online next day delivery - tramadol dosage veterinary

Anonymous said...

diazepam injection what is diazepam 5mg tablet - is diazepam for dogs the same as for humans

Anonymous said...

buy xanax online cod order xanax online pharmacy - xanax side effects in cats

Anonymous said...

buy tramadol cod next day delivery buy tramadol 99 - tramadol hcl dosage adults

Anonymous said...

generic ambien online 10mg ambien beer - ambien prices pharmacies

Anonymous said...

buy tramadol online mastercard overnight buy tramadol hcl online - tramadol hcl mechanism of action

Anonymous said...

pharmacokinetics of diazepam buy diazepam online no prescription needed - diazepam dosage to get high

Anonymous said...

carisoprodol 350 mg medicamento carisoprodol 350 mg - dosage of carisoprodol

Anonymous said...

tramadol online pharmacy buy tramadol 50mg uk - tramadol xl

Anonymous said...

ambien online pharmacy time between ambien and alcohol - ambien fail drug test

Anonymous said...

buy tramadol tramadol purchase cheap - tramadol online no prescription

Anonymous said...

diazepam dog diazepam backorder - valium diazepam side effects

Anonymous said...

soma drug where to get soma persona 4 - soma good drug

Anonymous said...

order tramadol online without prescription good site buy tramadol - tramadol hcl or vicodin

Anonymous said...

ambien pharmacy does ambien high feel like - buy ambien online no rx

Anonymous said...

xanax anxiety order xanax online india - xanax zoloft and alcohol

Anonymous said...

diazepam without a prescription diazepam 2mg effects alcohol - diazepam starting dose

Anonymous said...

soma drug buy hgh - somatropin online - carisoprodol liver damage

Anonymous said...

order tramadol online mastercard tramadol versus vicodin - trusted online pharmacy tramadol

Anonymous said...

ambien online without rx high from ambien - generic ambien less effective

Anonymous said...

buy xanax online overnight xanax for chronic anxiety - xanax pills pregnancy

Anonymous said...

buy tramadol online without a prescription tramadol gets me high - buy tramadol 99

Anonymous said...

buy tramadol without prescriptions order tramadol eu - tramadol 250 mg

Anonymous said...

xanax buy alprazolam 1mg side effects - buy xanax no prescription needed

Anonymous said...

buy discount tramadol buy tramadol online utah - tramadol hcl good pain

Anonymous said...

buy tramadol order tramadol online mastercard - buy tramadol online us pharmacy

Anonymous said...

diazepam online buy diazepam online no prescription usa - dose of diazepam

Anonymous said...

tramadol online buy tramadol eu - tramadol usage

Anonymous said...

buy diazepam online buy diazepam online in australia - how long does diazepam 10mg last

Anonymous said...

buy tramadol cod overnight tramadol gets me high - tramadol hcl hcl

Anonymous said...

ambien pill buy ambien online safely - buy ambien sleeping tablets

Anonymous said...

buy soma order soma online no rx - soma wellbutrin drug interactions

Anonymous said...

tramadol generic tramadol hcl webmd - tramadol get high off it

Anonymous said...

buy tramadol online tramadol 50 mg extended release - tramadol hcl high effects

Anonymous said...

buy soma watson brand soma online - carisoprodol side effects alcohol

Anonymous said...

buy diazepam dosage for diazepam 2mg - valium drug test how long

Anonymous said...

ambien sleep ambien sleeping pill wiki - cheap generic ambien online

Anonymous said...

buy tramadol online tramadol online tennessee - ordering ultram online legal

Anonymous said...

soma cheap generic soma capsules - generic soma pill identification

Anonymous said...

buy ambien online no rx ambien side effects bloating - buy ambien overnight shipping

Anonymous said...

buy tramadol in florida tramadol dosage bluelight - buy tramadol sr 100 mg

Anonymous said...

buy soma online buy-soma.com - soma todos medos online dublado

Anonymous said...

tramadol buy buy tramadol hcl 50 mg - buy tramadol online no prescription overnight

Anonymous said...

cheapest xanax generic xanax vs xanax - xanax withdrawal ocd

Anonymous said...

buy tramadol online cod overnight tramadol hcl-acetaminophen zen - high does tramadol get you

Anonymous said...

buy tramadol online tramadol hcl bp monograph - tramadol dosage back pain

Anonymous said...

diazepam drug buy diazepam line no prescription - diazepam dosage kids

Anonymous said...

generic xanax online generic xanax india - drug test does xanax show up

Anonymous said...

soma cheap soma drug use - carisoprodol 350 mg street name

Anonymous said...

buy tramadol mastercard tramadol hcl 50mg for dogs - tramadol withdrawal high blood pressure

Anonymous said...

buy tramadol uk tramadol veterinary use dosage - order tramadol online without prescription

Anonymous said...

buy soma online 350mg carisoprodol erowid - carisoprodol 350mg high

Anonymous said...

xanax antidepressant xanax side effects drinking - side effects xanax extended release

Anonymous said...

generic xanax Arlington 1.5 mg xanax high - xanax jewelry

Anonymous said...

buy xanax bars xanax drug interactions side effects - usual dosage xanax

Anonymous said...

cheapest xanax can u overdose xanax - xanax online forum

Anonymous said...

order tramadol online mastercard buy tramadol online us - tramadol used get high

Anonymous said...

buy tramadol overnight shipping buy tramadol 100mg - buy tramadol online overnight shipping

Anonymous said...

xanax 2mg 1.5 mg xanax withdrawal - order xanax cod

Anonymous said...

buy xanax online no prescription overnight buy xanax online canada no prescription - xanax withdrawal length of time

Anonymous said...

alprazolam drug drug test valium xanax - xanax names

Anonymous said...

buy xanax xanax withdrawal symptoms sweating - blue xanax pills generic

Anonymous said...

generic alprazolam xanax withdrawal success stories - drug interactions xanax geodon

Anonymous said...

xanax online Columbus buy alprazolam online - xanax-effects.com

Anonymous said...

order tramadol tramadol bluelight - can you get tramadol online legally

Anonymous said...

where can i buy ambien online type high ambien - highest dosage ambien prescribed

Anonymous said...

xanax pill xanax withdrawal neck pain - what is xanax drug class

Anonymous said...

alprazolam drug buy xanax online no prescription cheap - xanax overdose much too much

Anonymous said...

xanax online Portland xanax overdose possible - xanax dosage how supplied

Anonymous said...

xanax online New Jersey 2mg xanax round pill - xanax withdrawal valerian

Anonymous said...

buy xanax xanax side effects body - generic xanax 15mg

Anonymous said...

buy xanax online Indianapolis xanax withdrawal + valerian root - what is xanax used for yahoo

Anonymous said...

xanax online no prescription buy xanax online forum - drug interactions concerta xanax

Anonymous said...

buy xanax online without rx xanax zyprexa - effects of quitting xanax cold turkey

Anonymous said...

buy ambien ambien side effects reviews - ambien cr 7 day free trial

Anonymous said...

buy xanax online no rx generic xanax pictures of pills - xanax zolarem 1mg

Anonymous said...

buy ambien buy ambien online with mastercard - ambien dosage 10

Anonymous said...

buy xanax online Texas xanax 1.0 side effects - order xanax bars

Anonymous said...

buy xanax New York xanax and alcohol high - xanax kava

Anonymous said...

buy xanax xanax for depression - xanax online safe

Anonymous said...

xanax online prescription effects xanax vicodin - drug schedule of xanax

Anonymous said...

alprazolam 0.5mg buy xanax online cheap no prescription - xanax dosage weight

Anonymous said...

buying ambien online where to buy ambien in canada - ambien cr extended release

Anonymous said...

buy xanax online xanax and alcohol combination - xanax overdose do

Anonymous said...

ambien buy ambien cr dosage information - ambien dosage 20

Anonymous said...

buy xanax online Seattle can overdose xanax kill you - xanax side effects sleep

Anonymous said...

ambien online pharmacy ambien lithium drug interactions - buy ambien online legally

Anonymous said...

buy xanax bars online does xanax show up drug test long - alprazolam gp 0 5mg

Anonymous said...

buy ambien generic name of ambien cr - ambien sleep meds

Anonymous said...

can you buy xanax online legally what is xanax medication used for - xanax much get high

Anonymous said...

buy ambien ambien quitting - mail order ambien

Anonymous said...

cheapest xanax generic xanax photos - xanax blood drug test

Anonymous said...

buy xanax online Kansas generic version of xanax - can you buy xanax cancun

Anonymous said...

ambien without a rx ambien meditation music online - generic ambien photos

Anonymous said...

buy xanax drug schedule of xanax - buy xanax discover card

Anonymous said...

xanax online Baltimore valium vs xanax recreational use - recovering xanax overdose

Anonymous said...

buy ambien online ambien vs xanax high - ambien drug guide

Anonymous said...

xanax online Iowa buy generic xanax no prescription - buy xanax online no prescription overnight

Anonymous said...

buy alprazolam xanax used opiate withdrawal - paxil for xanax for anxiety

Anonymous said...

generic zolpidem generic form of ambien cr - ambien cr using side effects

«Oldest ‹Older   1 – 200 of 257   Newer› Newest»