Search code examples
oraclehibernatehibernate-mapping

Hibernate mapping of two properties to one column


I have an object that is generated from XSDs, so I can't change it. In it I have a String DATE and a String TIME (representing the time of day without the date).

DATE = yyyy-mm-dd
TIME = hh:MM:ss:mmmm

In the OracleDB, I don't want to represent these as VARCHAR. I'd like to use DATE or DATETIME. Therefore, I'd need to map both DATE + TIME to one single column, DATETIME.


Solution

  • This is not possible. You can map two columns to a single property (using composites or user types) but not the other way around.

    Using the same column name twice in the mapping file usually results in strange exceptions (index out of bounds).

    I would use two columns in the database. Convert them to DATE-kind data types using a user type.