Guest User

Untitled

a guest
Dec 19th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. @Entity
  2. @Table(name="pushmaster")
  3. public class Pushdata {
  4.  
  5. @Id
  6. @SequenceGenerator(name = "pushmaster_id_seq",
  7. sequenceName = "pushmaster_id_seq",
  8. allocationSize = 1)
  9. @GeneratedValue (strategy = GenerationType.SEQUENCE,
  10. generator = "pushmaster_id_seq")
  11. @Column(name="id", unique = true)
  12. public int id;
  13.  
  14. private String title;
  15. private String content;
  16.  
  17. public Pushdata (){
  18.  
  19. }
  20.  
  21. public Pushdata (String title, String content){
  22. this.title=title;
  23. this.content=content;
  24. }
  25.  
  26. @Column(name = "title")
  27. public String getTitle() {
  28. return title;
  29. }
  30.  
  31. public void setTitle(String title) {
  32. this.title = title;
  33. }
  34.  
  35. @Column(name = "content")
  36. public String getContent() {
  37. return content;
  38. }
  39.  
  40. public void setContent(String content) {
  41. this.content = content;
  42. }
  43.  
  44.  
  45. public int getId() {
  46. return id;
  47. }
  48.  
  49. public void setId(int id) {
  50. this.id = id;
  51. }}
  52.  
  53. (List<Pushdata>)
  54. factoryClass.getSessionFactory().
  55. openSession().createQuery(" from Pushdata" ).list();
  56.  
  57. <hibernate-configuration>
  58. <session-factory>
  59.  
  60. <property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
  61. <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQL94Dialect</property>
  62.  
  63. <property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/</property>
  64.  
  65. <property name="hibernate.connection.username">postgres</property>
  66. <property name="hibernate.connection.password">password</property>
  67.  
  68. <property name="connection_pool_size">1</property>
  69.  
  70. <property name="hbm2ddl.auto">update</property>
  71.  
  72. <property name="hibernate.connection.autocommit">true</property>
  73.  
  74. <property name="show_sql">true</property>
  75.  
  76. <mapping class="ru.spb.Pushdata"/>
  77.  
  78. </session-factory>
Add Comment
Please, Sign In to add comment