Skip to Main Content

Oracle Database Express Edition (XE)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Oracle dialect does not support identity key generation

576227Nov 19 2012 — edited Nov 19 2012
Hello,

I'm trying to run an integration tests suite against an Oracle 10g XE database server on a Linux box. But I have one issue that makes all the tests in error. Here is the message I get for each and every test:

]Results :

Tests in error:
testSaveAndRetrieve(com.thalasoft.learnintouch.cor e.dao.AdminDaoTest): com.thalasoft.learnintouch.core.dao.dialect.Custom Oracle10gDialect does not support identity key generation; nested exception is org.hibernate.MappingException: com.thalasoft.learnintouch.core.dao.dialect.Custom Oracle10gDialect does not support identity key generation

I wonder what kind of domain classes mapping setup is required for Hibernate to correctly talk to Oracle.

Also, I hope I can keep the domain classes mapping setup common to MySql and Oracle and not be forced to have one specific for each database server.

I'm using the Oracle driver ojdbc14 10.2.0.4.0 with Spring 3.1.3.RELEASE and Hibernate 3.6.9.Final versions.

Here is my Hibernate Spring setup and a domain class mapping setup:

<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="mappingDirectoryLocations">
<list>
<value>classpath:com/thalasoft/learnintouch/core/domain</value>
</list>
</property>
<property name="mappingResources">
<list>
<value>com/thalasoft/learnintouch/core/domain/typedef.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
<prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.c3p0.min_size">5</prop>
<prop key="hibernate.c3p0.max_size">20</prop>
<prop key="hibernate.c3p0.timeout">1800</prop>
<prop key="hibernate.c3p0.max_statements">50</prop>
</props>
</property>
</bean>

<!-- Setup the Spring transaction manager -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>

<tx:annotation-driven />

<bean class="org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor" />

<!-- Translate dao exceptions into Spring exceptions -->
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />

The Hibernate mapping:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.thalasoft.learnintouch.core.domain.Admin" table="admin"
dynamic-insert="true" dynamic-update="true">
<id name="id" type="java.lang.Integer">
<column name="id" />
<generator class="identity" />
</id>
<version name="version" type="int">
<column name="version" not-null="true" />
</version>
<property name="login" type="string">
<column name="login" length="50" not-null="true" unique="true" />
</property>
<property name="password" type="string">
<column name="password" length="100" not-null="true" />
</property>
<property name="passwordSalt" type="string">
<column name="password_salt" length="50" />
</property>
<property name="firstname" type="string">
<column name="firstname" not-null="true" />
</property>
<property name="lastname" type="string">
<column name="lastname" not-null="true" />
</property>
<property name="email" type="string">
<column name="email" not-null="true" />
</property>
<property name="superAdmin" type="boolean">
<column name="super_admin" not-null="true" />
</property>
<property name="preferenceAdmin" type="boolean">
<column name="preference_admin" not-null="true" />
</property>
<property name="address" type="string">
<column name="address" />
</property>
<property name="zipCode" type="string">
<column name="zip_code" length="10" />
</property>
<property name="city" type="string">
<column name="city" />
</property>
<property name="country" type="string">
<column name="country" />
</property>
<property name="profile" type="text">
<column name="profile" length="65535" />
</property>
</class>
</hibernate-mapping>

I'm also using a custom dialect:

public class CustomOracle10gDialect extends Oracle10gDialect {

public CustomOracle10gDialect() {
super();
registerColumnType(Types.LONGVARCHAR, "clob");
registerColumnType(Types.LONGNVARCHAR, "clob");
registerColumnType(Types.INTEGER, "number");
registerColumnType(Types.BIT, "number");
registerColumnType(Types.TIMESTAMP, "date");
}

}

The schema definition:

create table admin (
id number(10) not null,
version number(10) not null,
firstname varchar2(255) not null,
lastname varchar2(255) not null,
login varchar2(50) not null,
constraint admin_login_u1 unique (login),
password varchar2(100) not null,
password_salt varchar2(50),
super_admin number(1) not null check (super_admin in (0, 1)),
preference_admin number(1) not null check (preference_admin in (0, 1)),
address varchar2(255),
zip_code varchar2(10),
city varchar2(255),
country varchar2(255),
email varchar2(255),
profile clob,
constraint admin_pk primary key (id)
);
create sequence sq_id_admin increment by 1 start with 1 nomaxvalue nocycle cache 10;
create or replace trigger tr_id_inc_admin
before insert
on admin
for each row
declare
begin
select sq_id_admin.nextval into :new.id from dual;
end;
/

Comments

Dude!
Answer
VirtualBox can run VMs created by VMware Workstation or Server.

RHEL/CentOS/OEL:
# sudo yum install qemu

Ubuntu, Debian:
# sudo apt-get install qemu

1. Convert a VMWare Image to VirtualBox Image:
# qemu-img convert vmware.vmdk /tmp/vbox.bin

2. Use VBoxManage to convert image:
# VBoxManage convertdd /tmp/vbox.bin vbox.vdi

- Start Virtual Box
- Goto File > Virtual Disk Manager
- Click Add.  Locate and select the copied .vmdk file. Click OK.
- Create a New VM as usual using the added vmdk file
- Boot the VM


To convert virtualbox image in to vmware image you can use following:

1. Convert .vdi file in to .raw file
# VBoxManage internalcommands converttoraw vbox.vdi vbox.raw

2. Convert .raw file into .vmdk
# qemu-img convert -O vmdk vbox.raw test.vmdk
Marked as Answer by 732975 · Sep 27 2020
732975
Genius! Thank you Markus!
I've used VMware fusion (which is for mac, as you know it), but will that make any difference from the ones
created by VMware Workstation or Server ?

Edited by: user1175367 on Jul 28, 2010 3:49 PM
732975
comments as above.
Dude!
I do not use WMware Fusion on my Macbook Pro anymore since I needed Firewire support and therefore use rEFlt with native triple boot now.

Q.app, which is Qemu for MacOSX. It can be found here:
http://www.kju-app.org/

Qemu supports the following formats: qcow2 vvfat vpc bochs dmg cloop vmdk qcow host_device raw
# qemu-img.exe convert -O vmdk hdd.vdi hdd.vmdk

VMware provides a tool called VMware Converter. VMware Converter eases interoperability among VMware hosted products (Workstation, VMware Server, VMware Player, and Fusion), VirtualCenter-managed ESX Server 3.x and 2.5.x, and unmanaged ESX Server 3.x.

http://www.vmware.com/support/converter/doc/releasenotes_conv302.html

It's for Windows platform only, but below can be used to convert a Windows system running inside Virtualbox to WMware fusion on Mac.
http://www.vmware.com/download/fusion/windows_to_mac.html
732975
thank you
1 - 5
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Dec 17 2012
Added on Nov 19 2012
1 comment
7,615 views