I honestly don't know what else to do. I've looked everywhere, but nothing. Anyone, please, help...
In my reverse engineering file, I'm trying to alter the primary key generator class of one of my tables to "identity". On the database (ms sql 2012) the primary key column is set to identity, but hibernate interprets that as "assigned", so I'm trying to correct that problem.
This is what I put in my reverse engineering xml file:
<table name="TITLE">
<primary-key>
<generator class="identity"/>
<key-column name="id"/>
</primary-key>
</table>
And yet, the <table>
tag does not appear to be taken into consideration. Please, what am I doing wrong? Am I missing something?
Due to many differences between database and JDBC driver versions, the more general solution is to place a breakpoint in the org.hibernate.mapping.Table
constructor and then run Maven hibernate3:hbm2java
in the debugger, and look at the values that are passed down the call chain, eg:
Table.<init>() line: 105
Mappings.addTable(String, String, String, String, boolean) line: 188
MappingsDatabaseCollector.addTable(String, String, String) line: 21
In my case I found the catalog
and schema
were both null
. My <table>
tag was ignored until I removed the catalog
and schema
attributes.
I just figured it out. You have to include both the schema AND the catalog. The catalog, in my case, is the database name:
<table name="TITLE" catalog="hibernatetest" schema="dbo" class="Jeffery_jump">
<primary-key>
<generator class="identity"/>
<key-column name="id" property="version"/>
</primary-key>
</table>
What's annoying is according to the official hibernate documentation, schema and catalog are optional. Well done, hibernate. Well done.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.