简体   繁体   中英

How to handle insert with Hibernate and ColdFusion on the primary key

I have been trying to solve this one for a while. What is the correct approach for inserting into a table using Hibernate and ColdFusion 10 and Oracle 11g? Nothing seems to work. I have tried almost everything in the documentation .

Here is the code that I have:

property name="ID" column="ID" 
       type="numeric" 
       ormtype="double" 
       fieldtype="id" 
       generator="native"; 

The answer was in the link you provided. For Oracle, you need to provide information about which sequence to use for auto-increment IDs.

<cfproperty name="id" fieldtype="id" 
     generator="sequence" 
     params="{sequence='id_sequence'}">

After much looking around and testing this is the solution that I found which works in Oracle 11g and ColdFusion 10 on Solaris. I simply need to change the ormtype="double" to ormtype="int" I handled the sequence by doing this. generator="sequence" sequence="sequencename" Here is the code.

property name="ID" column="ID" type="numeric" ormtype="int" fieldtype="id" generator="sequence" sequence="sequencename"; 

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM