Guest User

Untitled

a guest
Aug 12th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.33 KB | None | 0 0
  1. @Column(length=1000000)
  2. @Lob
  3. private String notes;
  4.  
  5. <property name="hibernate.hbm2ddl.auto" value="update" />
  6.  
  7. import javax.persistence.Column;
  8. import javax.persistence.Entity;
  9. import javax.persistence.GeneratedValue;
  10. import javax.persistence.Id;
  11. import javax.persistence.Lob;
  12. import javax.persistence.NamedQuery;
  13. import javax.persistence.Table;
  14.  
  15. @Entity
  16. @Table( name = "usr" )
  17.  
  18. public class User {
  19. @Id
  20. @GeneratedValue
  21. private Long id;
  22.  
  23. @Column( length = 40, unique = true )
  24. private String name;
  25.  
  26. @Lob
  27. @Column( length = 100000 )
  28. private String text;
  29.  
  30. public long getId() {
  31. return id;
  32. }
  33.  
  34. public void setName( String name ) {
  35. this.name = name;
  36. }
  37.  
  38. public String getName() {
  39. return name;
  40. }
  41.  
  42. public String getText() {
  43. return text;
  44. }
  45.  
  46. public void setText( String text ) {
  47. this.text = text;
  48. }
  49.  
  50. }
  51.  
  52. <persistence xmlns="http://java.sun.com/xml/ns/persistence"
  53. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  54. xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
  55. version="2.0">
  56. <persistence-unit name="jpatest" transaction-type="RESOURCE_LOCAL">
  57. <properties>
  58. <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
  59. <property name="hibernate.hbm2ddl.auto" value="update"/>
  60. <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
  61. <property name="hibernate.connection.username" value="root"/>
  62. <property name="hibernate.connection.password" value="root"/>
  63. <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/jpadatabase"/>
  64. <property name="hibernate.show-sql" value="true"/>
  65. </properties>
  66. </persistence-unit>
  67. </persistence>
  68.  
  69. .....
  70.  
  71. @Column( length = 255 )
  72. private String text;
  73. ......
  74.  
  75. DEBUG SchemaExport:415 - drop table if exists usr
  76. DEBUG SchemaExport:415 - create table usr (id bigint not null auto_increment, name varchar(40) unique, text varchar(255), primary key (id)) ENGINE=InnoDB
  77. INFO SchemaExport:281 - schema export complete
  78.  
  79. .....
  80. @Lob
  81. @Column( length = 100000 )
  82. private String text;
  83. .......
  84.  
  85. DEBUG SchemaExport:415 - drop table if exists usr
  86. DEBUG SchemaExport:415 - create table usr (id bigint not null auto_increment, name varchar(40) unique, text longtext, primary key (id)) ENGINE=InnoDB
  87. INFO SchemaExport:281 - schema export complete
  88.  
  89. INFO TableMetadata:65 - table found: jpadatabase.usr
  90. INFO TableMetadata:66 - columns: [id, text, name]
  91. INFO TableMetadata:68 - foreign keys: []
  92. INFO TableMetadata:69 - indexes: [name, primary]
  93. DEBUG DefaultIdentifierGeneratorFactory:90 - Setting dialect [org.hibernate.dialect.MySQL5InnoDBDialect]
  94. INFO SchemaUpdate:217 - schema update complete
  95.  
  96. DEBUG SchemaUpdate:203 - alter table usr add column location varchar(255)
  97. INFO SchemaUpdate:217 - schema update complete
  98.  
  99. ALTER TABLE piece_aud MODIFY notes LONGTEXT;
  100.  
  101. ALTER TABLE piece_aud MODIFY notes LONGTEXT;
  102.  
  103. <property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.ImprovedNamingStrategy"/>
  104.  
  105. alter table your_table modify column your_column text
  106.  
  107. @Type(type="org.hibernate.type.StringClobType")
  108. String message;
  109.  
  110. @Column(name="your_column_name",columnDefinition="LONGTEXT")
  111. private String notes;
Add Comment
Please, Sign In to add comment