[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Hibernate 3, MySQL and nullable timestamp
sarbogast
do-not-reply at jboss.com
Sat Aug 25 14:43:31 EDT 2007
I've got an issue with Hibernate 3 hbm2ddl and my MySQL 5.0 database
One of my entities has a field that is mapped onto a TIMESTAMP column. This field can be null but in MySQL, a TIMESTAMP can only be null if specified in the column declaration. From MySQL documentation:
anonymous wrote :
| TIMESTAMP columns are NOT NULL by default, cannot contain NULL values, and assigning NULL assigns the current timestamp. However, a TIMESTAMP column can be allowed to contain NULL by declaring it with the NULL attribute. In this case, the default value also becomes NULL unless overridden with a DEFAULT clause that specifies a different default value.
|
Unfortunately, the following mapping:
| <hibernate-mapping default-cascade="none">
| <class name="com.thalys.opalys.domain.IncidentImpl" table="INCIDENT" dynamic-insert="false" dynamic-update="false">
| <!--...-->
| <property name="endDate" >
| <column name="END_DATE" not-null="false" unique="false" sql-type="TIMESTAMP"/>
| <type name="org.joda.time.contrib.hibernate.PersistentLocalDate">
| </type>
| </property>
| <!--...-->
| </class>
| </hibernate-mapping>
|
Produces the following CREATE TABLE when hdm2ddl runs:
| create table INCIDENT (
| --...
| END_DATE TIMESTAMP,
| --...
| ) type=InnoDB;
|
Did I miss something or is it a bug?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4078058#4078058
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4078058
More information about the jboss-user
mailing list