F
fthomas
Dear all,
I'm getting squeezed between Struts and Hibernate when I use Date type
for a record.
My setup is the simplest possible.
This is my mappings file
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.ft.ht.DictatorForm" table="DICTATOR">
<meta attribute="class-description">
testing Struts with Hibernate
</meta>
<id name="id" type="int" column="DICTATOR_ID">
<meta attribute="scope-set">protected</meta>
<generator class="native"/>
</id>
<property name="added" column="ADDED" type="timestamp"/>
<property name="firstName" type="java.lang.String" not-null="true"
column="FIRST_NAME"/>
<property name="lastName" type="java.lang.String" not-null="true"
column="LAST_NAME"/>
<property name="birthDate" column="BIRTH_DATE" type="timestamp"/>
<property name="offsprings" type="short" column="OFFSPRINGS"/>
</class>
</hibernate-mapping>
The timestamp type gets translated into java.util.Data in the POJO and
in datetime in the
database schema. I heve MySQL as my DB.
I use the above mapping to generate a POJO which then I modify to
extend ActionForm.
I have to modify then all the setters to accept String (instead of
java.util.Date), that's to make
Struts happy.
The trouble is that Hibernate is unhappy with the setter. When I try
to commit something with Date I get :
org.hibernate.PropertyAccessException: IllegalArgumentException
occurred while calling setter of com.ft.ht.DictatorForm.birthDate
If the setters are let to accept Date then Strings shouts at me...
So far I was experimenting only with Strings and Dates. If I go only
with String everything is working...
What am I to do then? Can somebody point me to a complete example
which uses Hibernate with Struts and
commits multiple types of data to the Database (MySQL)
Cheers,
Thomas
I'm getting squeezed between Struts and Hibernate when I use Date type
for a record.
My setup is the simplest possible.
This is my mappings file
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.ft.ht.DictatorForm" table="DICTATOR">
<meta attribute="class-description">
testing Struts with Hibernate
</meta>
<id name="id" type="int" column="DICTATOR_ID">
<meta attribute="scope-set">protected</meta>
<generator class="native"/>
</id>
<property name="added" column="ADDED" type="timestamp"/>
<property name="firstName" type="java.lang.String" not-null="true"
column="FIRST_NAME"/>
<property name="lastName" type="java.lang.String" not-null="true"
column="LAST_NAME"/>
<property name="birthDate" column="BIRTH_DATE" type="timestamp"/>
<property name="offsprings" type="short" column="OFFSPRINGS"/>
</class>
</hibernate-mapping>
The timestamp type gets translated into java.util.Data in the POJO and
in datetime in the
database schema. I heve MySQL as my DB.
I use the above mapping to generate a POJO which then I modify to
extend ActionForm.
I have to modify then all the setters to accept String (instead of
java.util.Date), that's to make
Struts happy.
The trouble is that Hibernate is unhappy with the setter. When I try
to commit something with Date I get :
org.hibernate.PropertyAccessException: IllegalArgumentException
occurred while calling setter of com.ft.ht.DictatorForm.birthDate
If the setters are let to accept Date then Strings shouts at me...
So far I was experimenting only with Strings and Dates. If I go only
with String everything is working...
What am I to do then? Can somebody point me to a complete example
which uses Hibernate with Struts and
commits multiple types of data to the Database (MySQL)
Cheers,
Thomas