<?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="jpaPU" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.connection.driver_class" value="com.MysqL.jdbc.Driver"/>
<property name="hibernate.connection.url" value="jdbc:MysqL://localhost:3306/test"></property>
<property name="hibernate.connection.username" value="root"></property>
<property name="hibernate.connection.password" value="root"></property>
<property name="hibernate.show_sql" value="true"></property>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MysqLInnoDBDialect"></property>
<property name="hibernate.current_session_context_class" value="thread"></property>
</properties>
</persistence-unit>
<!--
<persistence-unit name="jpaPU" transaction-type="JTA">
<jta-data-source>jndi_MysqL</jta-data-source>
</persistence-unit>
-->
</persistence>
- packageuser1;
- importjavax.persistence.Column;
- importjavax.persistence.Entity;
- importjavax.persistence.GeneratedValue;
- importjavax.persistence.GenerationType;
- importjavax.persistence.Id;
- importjavax.persistence.Table;
- @Entity
- @Table(name="user_table")
- publicclassUser1{
- @Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- privateintid;
- @Column(name="name",length=10)
- privateStringname;
- @Column(name="pass")
- privateStringpass;
- publicUser1(){}
- intgetId(){
- returnid;
- }
- voidsetId(intid){
- this.id=id;
- publicStringgetName(){
- returnname;
- voidsetName(Stringname){
- this.name=name;
- publicStringgetPass(){
- returnpass;
- voidsetPass(Stringpass){
- this.pass=pass;
- }