I have a entity class group.
before change
@Entity
@Table(name = "Group")
public class Group implements Serializable {
private static final long serialVersionUID = 1L;
private Long id;
private String name;
@Deprecated
public Group() {
// Do not Use. Required by JPA Spec
}
public Group(Long id) {
this.id = id;
}
@Id
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@NotNull
@Size(min = 2, max = 75)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public boolean equals(Object o) {
if (o instanceof User) {
return getId().equals(((Group) o).getId());
}
else {
return false;
}
}
Now I changed the max size of the name from 75 to 1000.
@Entity
@Table(name = "Group")
public class Group implements Serializable {
private static final long serialVersionUID = 1L;
private Long id;
private String name;
@Deprecated
public Group() {
// Do not Use. Required by JPA Spec
}
public Group(Long id) {
this.id = id;
}
@Id
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@NotNull
@Size(min = 2, max = 1000)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public boolean equals(Object o) {
if (o instanceof User) {
return getId().equals(((Group) o).getId());
}
else {
return false;
}
}
After this change the length of the name in the database is not getting changd from 75 to 1000.
The persistance.xml looks like
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1"
xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="primary" transaction-type="JTA">
<jta-data-source>java:jboss/datasources/sampleDS</jta-data-source>
<properties>
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
</properties>
</persistence-unit>
</persistence>