I want to map referenced object(Spec) in main Object as User Type. I created main Object(Request) and it as a property column EXPIRE_TIMESTAMP which maps to
@hibernate.property column="EXPIRE_TIMESTAMP" type="com.SpecHibernatePersistenceType" inside Request object.
I implemeted a UserType to map between Date in SpecHibernatePersistenceType and Date column in Oracle.
The Date inserted in oracle does not contain time, it only contains date part(ex:11/07/04, no 6:23:43 PM part)
For example, say I have a managed object like this:
public class Request
{
....
private Spec spec;
....
}
which is mapped like this
....
@hibernate.property column="EXPIRE_TIMESTAMP" type="com.SpecHibernatePersistenceType"
....
and UserType : SpecHibernatePersistenceType
public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException
{
if (value == null) {
st.setNull(index, Types.DATE);
} else {
st.setDate(index, new java.sql.Date(((Spec) value.getExpireTimeStamp().getTime()) );
}
}
Iam using java.sql.Date here because my Spec member variable expireTimestamp is of java.util.Date type.
public class Spec
{
private java.util.Date expireTimestamp;
}
Thanks,
Kyama
Hibernate version:
2.1.6
Mapping documents:
n/a
Code between sessionFactory.openSession() and session.close():
n/a
Full stack trace of any exception that occurs:
n/a
Name and version of the database you are using:
Oracle 9i
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
[/code]
|