Entity Bean (2) Development entity class, Annotation

Source: Internet
Author: User

1. Develop entity classes

 Package Com. Persia. JPA; Import Javax. Persistence. entity; Import Javax. Persistence. generatedvalue; Import Javax. Persistence. ID; @ entity Public   Class Person { Private   Int ID; Private String name; @ ID @ generatedvalue Public   Int GETID (){ Return ID ;}Public   Void Setid ( Int ID ){ This . ID = ID ;} Public String getname (){ Return Name ;} Public   Void Setname (string name ){ This . Name = Name ;}}

 

2. Add the hibernate attribute in persistence. XML to automatically create a database table through deployment.

 <? XML version = "1.0" encoding = "UTF-8" ?>  < Persistence   Xmlns = Http://java.sun.com/xml/ns/persistence"      Xmlns : Xsi = Http://www.w3.org/2001/XMLSchema-instance"      Xsi : Schemalocation = Http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"   Version = "1.0"  >      < Persistence - Unit   Name = "Jpa01pu"   Transaction - Type = "JTA"  >    <  JTA - Data - Source  > Java:/JPA </  JTA -Data-Source>    <  Properties  >    <  Property   Name = "Hibernate. dialect"   Value = "Org. hibernate. dialect. mysqldialect"  />    <  Property   Name = "Hibernate. hbm2dll. Auto"   Value = "Update"  />    </  Properties  >  </  Persistence -Unit >    </  Persistence  > 

I didn't generate a table automatically here, and I don't know where to configure it.

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.