Advertisement
Guest User

Untitled

a guest
Oct 13th, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.84 KB | None | 0 0
  1. package org.com.etown.onetoone;
  2.  
  3. import javax.persistence.Entity;
  4. import javax.persistence.GeneratedValue;
  5. import javax.persistence.GenerationType;
  6. import javax.persistence.Id;
  7. import javax.persistence.OneToOne;
  8.  
  9. @Entity
  10. public class UserDetails {
  11. @Id @GeneratedValue(strategy = GenerationType.AUTO)
  12. private int userid;
  13. private String userName;
  14.  
  15. public int getUserid() {
  16. return userid;
  17. }
  18. public void setUserid(int userid) {
  19. this.userid = userid;
  20. }
  21. public String getUserName() {
  22. return userName;
  23. }
  24. public void setUserName(String userName) {
  25. this.userName = userName;
  26. }
  27.  
  28. }
  29.  
  30. package org.com.etown.onetoone;
  31.  
  32. import org.hibernate.Session;
  33. import org.hibernate.SessionFactory;
  34. import org.hibernate.cfg.Configuration;
  35.  
  36. public class UserDatailsDao {
  37.  
  38. public static void main(String[] args) {
  39.  
  40. UserDetails user = new UserDetails();
  41. user.setUserName("george");
  42.  
  43. SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
  44. Session session = sessionFactory.openSession();
  45. session.beginTransaction();
  46. session.save(user);
  47. session.getTransaction().commit();
  48. session.close();
  49.  
  50.  
  51. }
  52.  
  53. }
  54.  
  55. <?xml version="1.0" encoding="utf-8"?>
  56. <!DOCTYPE hibernate-configuration SYSTEM
  57. "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
  58.  
  59. <hibernate-configuration>
  60. <session-factory>
  61. <!-- Database connection settings -->
  62. <property name="connection.driver_class">org.postgresql.Driver</property>
  63. <property name="connection.url">jdbc:postgresql://localhost:5432/etowndb</property>
  64. <property name="connection.username">postgres</property>
  65. <property name="connection.password">root</property>
  66.  
  67. <!-- JDBC connection pool (use the built-in) -->
  68. <property name="connection.pool_size">1</property>
  69.  
  70. <!-- SQL Dialect -->
  71. <property name="dialect">org.hibernate.dialect.PostgreSQL92Dialect</property>
  72.  
  73. <!-- Disable the second level class -->
  74. <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
  75.  
  76. <!-- Echo all executed SQL to stdout -->
  77. <property name="show_sql">true</property>
  78.  
  79. <!-- Drop and re-creat the database schema on startup -->
  80. <property name="hbm2ddl.auto">update</property><!-- update,create -->
  81.  
  82. <!-- Names of the annotated entity class -->
  83. <mapping class="org.com.etown.onetoone.UserDetails"/>
  84.  
  85. </session-factory>
  86. </hibernate-configuration>
  87.  
  88. Oct 13, 2016 12:46:30 PM org.hibernate.Version logVersion
  89. INFO: HHH000412: Hibernate Core {5.1.1.Final}
  90. Oct 13, 2016 12:46:30 PM org.hibernate.cfg.Environment <clinit>
  91. INFO: HHH000206: hibernate.properties not found
  92. Oct 13, 2016 12:46:30 PM org.hibernate.cfg.Environment buildBytecodeProvider
  93. INFO: HHH000021: Bytecode provider name : javassist
  94. Oct 13, 2016 12:46:30 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
  95. INFO: HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
  96. Oct 13, 2016 12:46:30 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
  97. WARN: HHH10001002: Using Hibernate built-in connection pool (not for production use!)
  98. Oct 13, 2016 12:46:30 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
  99. INFO: HHH10001005: using driver [org.postgresql.Driver] at URL [jdbc:postgresql://localhost:5432/etowndb]
  100. Oct 13, 2016 12:46:30 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
  101. INFO: HHH10001001: Connection properties: {user=postgres, password=****}
  102. Oct 13, 2016 12:46:30 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
  103. INFO: HHH10001003: Autocommit mode: false
  104. Oct 13, 2016 12:46:30 PM org.hibernate.engine.jdbc.connections.internal.PooledConnections <init>
  105. INFO: HHH000115: Hibernate connection pool size: 1 (min=1)
  106. Oct 13, 2016 12:46:30 PM org.hibernate.dialect.Dialect <init>
  107. INFO: HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL92Dialect
  108. Oct 13, 2016 12:46:31 PM org.hibernate.engine.jdbc.env.internal.LobCreatorBuilderImpl useContextualLobCreation
  109. INFO: HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
  110. Oct 13, 2016 12:46:31 PM org.hibernate.type.BasicTypeRegistry register
  111. INFO: HHH000270: Type registration [java.util.UUID] overrides previous : org.hibernate.type.UUIDBinaryType@7ffeac8e
  112. Oct 13, 2016 12:46:31 PM org.hibernate.resource.transaction.backend.jdbc.internal.DdlTransactionIsolatorNonJtaImpl getIsolatedConnection
  113. INFO: HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@31c08b2e] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode.
  114. Oct 13, 2016 12:46:31 PM org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl processGetTableResults
  115. INFO: HHH000262: Table not found: UserDetails
  116. Oct 13, 2016 12:46:31 PM org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl processGetTableResults
  117. INFO: HHH000262: Table not found: UserDetails
  118. Hibernate: create table UserDetails (userid int4 not null, userName varchar(255), primary key (userid))
  119. Oct 13, 2016 12:46:31 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper$StandardWarningHandler logWarning
  120. WARN: SQL Warning Code: 0, SQLState: 00000
  121. Oct 13, 2016 12:46:31 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper$StandardWarningHandler logWarning
  122. WARN: CREATE TABLE / PRIMARY KEY will create implicit index "userdetails_pkey" for table "userdetails"
  123. Hibernate: select nextval ('hibernate_sequence')
  124.  
  125. @GeneratedValue(strategy = GenerationType.AUTO)
  126.  
  127. @GeneratedValue(strategy = GenerationType.IDENTITY)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement