Hibernate rapid development with eclipse

Source: Internet
Author: User

One: Create a Web project

Second: Connect to our Oracle database by providing a database browser via MyEclipse


Delete automatically appearing files, right-click New


Connect to MySQL Database


Read Local Database


Open the Database Operations panel


Introducing Hibernate Development Packages





Reverse engineering, creating classes from tables





Direct finish


Three: Write a test code

Import the development tools class for the previous project

Session session=null;

transactionts=null;

Try {

Session=hibernateutil. getcurrentsession ();

Ts=session.begintransaction ();

usersusers=NewUsers ();

Users.setname ("Cloud");

Users.setpwd ("8745");

Users.setemail ("[email protected]");

Users.settel ("12345");

Users.setgrade (1);

session.persist (users);

Ts.commit ();

}catch(Exception e) {

if (ts!=null)

{

Ts.rollback ();

}

thrownew RuntimeException ();

}finally{

if (session!=null &&session.isopen ()) {

Session.close ();

}

}



Copyright Notice: Bo Master original articles, reproduced please indicate the source. Http://blog.csdn.net/dzy21

Hibernate rapid development with eclipse

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.