-->
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.  [ 2 posts ] 
Author Message
 Post subject: how can i save object within one connection?
PostPosted: Sun Nov 19, 2006 10:12 am 
Newbie

Joined: Sun Nov 19, 2006 9:38 am
Posts: 1
Hibernate version: 3.1.2

Mapping documents:
<hibernate-mapping package="com.dao.demo">
<class name="Words" table="Words">
<id name="id" type="java.lang.Long">
<column name="id" length="11" not-null="true" unique="true" sql-type="number" />
<generator class="increment" />
</id>

<property column="DESCRIPTION" length="1000" name="description" not-null="true" type="string" />
<property column="WORD" length="50" name="word" not-null="true" type="string" />

<sql-insert callable="true">
{call pp.P_Insert_BanWord (?,?,?)}
</sql-insert>
</class>
</hibernate-mapping>


Name and version of the database you are using:oracle 10 g

The generated SQL (show_sql=true):yes

Debug level Hibernate log excerpt: info

I use 'sequence ' as my id generator, and when object words is saved ,it cost two connection. And the max connection of my db connection pool is 150.
When my system is busy, it ofen logs like this:
Cannot get a connection, pool exhausted
And the DBA of my system told me I shold save object within one connection to improve the performence of my system.

So, I think maybe I can use store procedure of oracle to solve my problem. And I write a store procedure like this:
CREATE OR REPLACE PROCEDURE "WORDS" (
p_word in varchar2,
p_description in varchar2,
p_temp_id in out number)
as
begin
insert into words values (
seq_words_id.nextval,
p_word,
p_description)
as
begin
insert into words values (
seq_words_id.nextval,
p_word,
p_description);
commit;
select seq_words_id.currval into p_temp_id from dual;
end;
/

and I use p_temp_id as my out parameter, I hope hibernate can get the return value as the true id for my system.

But i failed.

First my system is a cluster system, so I can't use "increment" as my id generator.
Next hibernate can't get the return value of my procedure as true object id value.

Just what shall I do if I want to improve the performence of my system. I want to cut down the db connection numbers from my system to db.
Thanx.


Last edited by lynnchai on Sun Nov 19, 2006 10:46 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 19, 2006 3:02 pm 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
I don't understand your problem. What do you do and what don't you manage to do ?

As I understand, you use your stored procedure to create words objects. Then, you load it using Hibernate ?

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.