Team,
I am using Hibernate 5.2.12 and trying a simple entity insertion and retrieval in a database. The Entity Mapping uses a sequence generator of native type. The HBMXML file looks like this
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class entity-name="customer" lazy="true" name="customer" table="customer">
<id name="CategoryID" type="int">
<column name="CategoryID"/>
<generator class="native"/>
</id>
<property name="name" type="string">
<column name="name"/>
</property>
<property name="address" type="string">
<column name="address"/>
</property>
<property name="DESCRIPTION" type="text">
<column name="DESCRIPTION"/>
</property>
</class>
</hibernate-mapping>
I am trying this simple scenario of Inserting an Entity and then retrieving it back, however with this Entity XML, the same works in SQLServer Database but not in Oracle.
I checked the Queries that are generated and found out that the query for inserting the data in Oracle is missing.
Here are the Queries that are generated:
For SQLServer:
Hibernate:
drop table customer
Hibernate:
create table customer (
CategoryID int identity not null,
name varchar(255),
address varchar(255),
DESCRIPTION varchar(MAX),
primary key (CategoryID)
)
Hibernate:
insert
into
customer
(name, address, DESCRIPTION)
values
(?, ?, ?)
Hibernate:
select
customer0_.CategoryID as Category1_0_,
customer0_.name as name2_0_,
customer0_.address as address3_0_,
customer0_.DESCRIPTION as DESCRIPT4_0_
from
customer customer0_
For ORACLE :
Hibernate:
drop table customer cascade constraints
Hibernate:
drop sequence hibernate_sequence
Hibernate: create sequence hibernate_sequence start with 1 increment by 1
Hibernate:
create table customer (
CategoryID number(10,0) not null,
name varchar2(255),
address varchar2(255),
DESCRIPTION long,
primary key (CategoryID)
)
Hibernate:
select
hibernate_sequence.nextval
from
dual
Hibernate:
select
customer0_.CategoryID as CategoryID1_0_,
customer0_.name as name2_0_,
customer0_.address as address3_0_,
customer0_.DESCRIPTION as DESCRIPTION4_0_
from
customer customer0_
As we can see there is no Insert Query generated for Oracle Database, Can someone please let me know what i am missing here and how can i resolve this?
Thanks and Appreciate Your Help in Advance.