persistent.xml

前端之家收集整理的这篇文章主要介绍了persistent.xml前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。


<?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>

Java代码
  1. packageuser1;
  2. importjavax.persistence.Column;
  3. importjavax.persistence.Entity;
  4. importjavax.persistence.GeneratedValue;
  5. importjavax.persistence.GenerationType;
  6. importjavax.persistence.Id;
  7. importjavax.persistence.Table;
  8. @Entity
  9. @Table(name="user_table")
  10. publicclassUser1{
  11. @Id
  12. @GeneratedValue(strategy=GenerationType.IDENTITY)
  13. privateintid;
  14. @Column(name="name",length=10)
  15. privateStringname;
  16. @Column(name="pass")
  17. privateStringpass;
  18. publicUser1(){}
  19. intgetId(){
  20. returnid;
  21. }
  22. voidsetId(intid){
  23. this.id=id;
  24. publicStringgetName(){
  25. returnname;
  26. voidsetName(Stringname){
  27. this.name=name;
  28. publicStringgetPass(){
  29. returnpass;
  30. voidsetPass(Stringpass){
  31. this.pass=pass;
  32. }

猜你在找的XML相关文章