Issue Details (XML | Word | Printable)

Key: HBX-700
Type: Bug Bug
Status: Reopened Reopened
Priority: Major Major
Assignee: Unassigned
Reporter: Genandiy Donchyts
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Hibernate Tools

Custom type mapping is not possible when reverse-engineering types that are not mapped uniquely to java.sql.Types

Created: 06/Jul/06 07:29 AM   Updated: 25/Jul/07 01:54 AM
Component/s: reverse-engineer
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Original Estimate: 1 hour
Original Estimate - 1 hour
Remaining Estimate: 1 hour
Remaining Estimate - 1 hour
Time Spent: Not Specified
Time Spent - Not Specified

File Attachments: 1. XML File hbm2java.cfg.xml (0.7 kB)
2. Text File schema.sql (0.0 kB)
3. XML File Test.hbm.xml (0.5 kB)

Environment: 3.2 svn, Oracle 10g, Oracle JDBC Driver version - "10.2.0.1.0"

Bug Testcase Reminder (view):
REMINDER: Bug reports should generally be accompanied by a test case
Participants: Genandiy Donchyts and Max Rydahl Andersen


 Description  « Hide

When reverse-engineering Oracle database containint column with TIMESTAMP(3) type it is not recognized as a TIMESTAMP and "serializable" type is used instead of timestamp. This happens because of the bug in Oracle JDBC driver since it returns OTHER (1111) instead of TIMESTAMP(93).

When type-mapping is provided in the form:

<type-mapping>
<sql-type jdbc-type="TIMESTAMP(3)" hibernate-type="timestamp" />
</type-mapping>

... it is not used because hibernate can't find TIMESTAMP(3) JDBC data type.

JDBCReader.java, processBasicColumns(Table table, ProgressListener progress):
...
//TODO: column.setSqlType(sqlTypeName); //this does not work 'cos the precision/scale/length are not retured in TYPE_NAME
//column.setSqlType(sqlTypeName);
...

it would be nice to have this sqlTypeName set to Column and used during comparison with <type-mapping>, then mapping from "TIMESTAMP(3)" to "timestamp" would work. Currently only 1111 ("OTHER") is passed to Column and as result column does not know anything about "TIMESTAMP(3)"


To reproduce an issue try to create simple Oracle database with one table:

create table test(id TIMESTAMP(3));

and run reverse-engineering task over it.

------

HACK: custom handling of TIMESTAMP types:

Modify JDBCReader.java:

private void processBasicColumns(Table table, ProgressListener progress) { // get the columns
...
String sqlTypeName = (String) columnRs.get("TYPE_NAME");
String columnName = (String) columnRs.get("COLUMN_NAME");

// HACK: custom handling of TIMESTAMP
if(sqlTypeName.startsWith("TIMESTAMP")) { sqlType = java.sql.Types.TIMESTAMP; }
...

See also forum post: http://forum.hibernate.org/viewtopic.php?t=961625&start=0&postdays=0&postorder=asc&highlight=



Genandiy Donchyts added a comment - 06/Jul/06 07:46 AM

results of reverse-engineering


Max Rydahl Andersen added a comment - 14/Sep/06 12:37 PM

should be solved by the issue that want to provide a db-type/native-type in type-mapping


Max Rydahl Andersen added a comment - 25/Jul/07 01:54 AM

can't find the duplicate issue so lets transform this one to what it is really about