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

164043
Ricardo, you can do that from CURL extension. You can set options via curl_setopt and
retrieve it with curl_multi_getcontent. Here is the man page:

http://hr.php.net/manual/en/ref.curl.php

Good luck.
I'll track down someone in the CRM on Demand group and get some background. But as I understand it at the moment, everything is available as a webservice, and the wsdl files are available on http://download.oracle.com/docs/cd/E14004_01/books/CRMWeb.zip Googling will give plenty of online references about using PHP to consume web services.

Documentation is at http://download.oracle.com/docs/cd/E14004_01/books/CRMWeb/CRMWeb81TOC.html
(The documentation portal with these references is at http://download.oracle.com/docs/cd/E14004_01/homepage.htm )
679538
Thanks, I reviewed the links, please, Can you give me some examples of how connect to CRM On Demand with PHP?
164043
I cannot speak for Chris but connecting to web server is essentially the same, regardless of the service provided by the web server. CURL and some parsing is what I would do in your position. Of course, I am not in your position.
164043
You can also use http_request PEAR package. The documentation is here:
http://pear.php.net/manual/en/package.http.http-request.php
751573
This is in PHP and will return the session ID.

$this->crmdomain points to your URL.

function login() {

$url = $this->crmdomain . "/Services/Integration?command=login";
$page = "/Services/Integration?command=login";
$headers = array("GET ".$page." HTTP/1.0",
"UserName: YOUR USERNAME",
"Password: YOUR PASSWORD",
);

$this->ch = curl_init();
curl_setopt($this->ch, CURLOPT_URL,$url);
curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($this->ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($this->ch, CURLOPT_HEADER, true);
$data = curl_exec($this->ch);


if (!curl_errno($this->ch)) {
$SessionId = substr($data,(strpos($data,"Set-Cookie:")+23),(strpos($data,";")-strpos($data,"Set-Cookie:")-23));
curl_close($this->ch);
return $SessionId;
} else {
return(0);
}

}//endof
1 - 6
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,696 views