is there any way to update the column definition of existing table where data is already present or may be table is empty.
Consider this:
@ManyToOne
@JoinColumn(name="type",nullable=false)
private EmpType type;
or
@JoinColumn(name="type",nullable=false)
private String type;
Considering any of above scenario, once hibernate initialized, it create tables column with Not Null
property. but When I change them from nullable=false
to nullable=true
this changes dont reflect in table. It still not null.
My Configuration is also include
<property name="hibernate.hbm2ddl.auto" value="update" />
Is there any other approach, or am I doing it in wrong way ?
Edit
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
version="1.0">
<persistence-unit name="myapp" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" />
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.show_sql" value="false" />
</properties>
</persistence-unit>
and in my spring application context:
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="persistenceUnitName" value="myapp" />
<property name="jpaPropertyMap">
<map>
<entry key="hibernate.ejb.interceptor"
value="org.springframework.orm.hibernate3.support.ScopedBeanInterceptor" />
</map>
</property>
</bean>