-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Problem with no values in insert statement
PostPosted: Mon Jan 02, 2006 11:27 am 
Newbie

Joined: Mon Jan 02, 2006 11:05 am
Posts: 2
Hello,

I have a table with exactly one column. This column uses a sequence in Oracle, and is set to autoincrement in MySQL. This table has also a one-to-many relation to another table.
When i try to update the tables, hibernate generates an sql statement that looks like this:

Code:
insert into ex_batch (batch_id) values ()


This works perfectly for MySQL, but not at all for Oracle, (ORA-00936: missing expression).
I use Hibernate 3.0.5 together with Jboss 4.0.3.

Is there anything to do except to explicitly set the value of the column and not use a sequence?


Börje Jonsson


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 03, 2006 5:19 am 
Newbie

Joined: Tue Jan 18, 2005 7:08 am
Posts: 10
I use Oracle's sequences too (but not MySQL).
For Oracle's sequences you should map your primary key something like that:

<id name="id" type="java.lang.Long" column="ID">
<generator class="sequence">
<param name="sequence">YOUR_ORACLE_SEQ</param>
</generator>
</id>


Top
 Profile  
 
 Post subject: Re: Problem with no values in insert statement
PostPosted: Tue Jan 03, 2006 6:12 am 
Newbie

Joined: Mon Jan 02, 2006 11:05 am
Posts: 2
Well, no that's not the problem.

The id part of my mapper file looks like this:

Code:
<id name="Id" type="integer" column="BATCH_ID">
    <generator class="native">
        <param name="sequence">ex_batch_seq</param>
    </generator>
</id>


The sequence exists and works.
The problem seems to be database dependent - Oracle doesn't like empty values "()" in insert statements.
I'm really asking to see if I made something wrong, of if there is some workaround.
Otherwise i have to explicitly supply the batch_id.

/BJ


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.