Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-19-2007, 04:56 AM
orchid's Avatar
Member
 
Join Date: Apr 2007
Location: Midwest
Posts: 60
orchid is on a distinguished road
Oracle sequences
I am wondering how to get oracle sequence to increment the primary key for my tables from my object.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-19-2007, 05:01 AM
Member
 
Join Date: Apr 2007
Location: Indiana
Posts: 84
pegitha is on a distinguished road
Send a message via Skype™ to pegitha
Can I see your mapping file?
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 04-19-2007, 05:06 AM
orchid's Avatar
Member
 
Join Date: Apr 2007
Location: Midwest
Posts: 60
orchid is on a distinguished road
Here
Code:
<?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 package="domain"> <class name="TfoType" table="TFO_TYPE" lazy="false"> <id name="id" type="java.lang.Integer" column="ID"> <generator class="assigned" /> </id> <property name="description" type="java.lang.String" column="DESCRIPTION" not-null="true" length="50" /> <property name="creationDate" type="java.sql.Timestamp" column="CREATION_DATE" not-null="true" length="7" /> <property name="createdBy" type="java.lang.String" column="CREATED_BY" not-null="true" length="8" /> <property name="lastUpdated" type="java.sql.Timestamp" column="LAST_UPDATED" length="7" /> <property name="lastUpdatedBy" type="java.lang.String" column="LAST_UPDATED_BY" length="8" /> <property name="recordStatus" type="java.lang.String" column="RECORD_STATUS" not-null="true" length="1" /> </class> </hibernate-mapping>

Last edited by orchid : 04-19-2007 at 05:08 AM.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 04-19-2007, 05:13 AM
Member
 
Join Date: Apr 2007
Location: Indiana
Posts: 84
pegitha is on a distinguished road
Send a message via Skype™ to pegitha
Depending on how your database is set up , that could work. But if it is not working, then try this:
Code:
<id name="id" type="java.lang.Integer" column="ID"> <generator class="sequence" /> <param name="sequence">TFO_TYPE_SEQ</param> </generator> </id>
It tells oracle that it is a sequence and exactly which one to use.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 04-19-2007, 07:50 AM
Senior Member
 
Join Date: Mar 2007
Posts: 136
goldhouse is on a distinguished road
Assumption : Using hibernate
Above assumes you are using hibernate for saving the entities,
Else you can simply say select sequencename.nextval from dual which will return the next value of the sequence and assign to some id and execute as a JDBC insert query
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 04-19-2007, 05:47 PM
orchid's Avatar
Member
 
Join Date: Apr 2007
Location: Midwest
Posts: 60
orchid is on a distinguished road
Yes, I am using Hibernate.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply

« - | oracle question »

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Generating number sequences hawkmauk New To Java 0 11-15-2007 05:32 PM
MS SQL2005 to Oracle DB bmongtangco JavaServer Pages (JSP) and JSTL 0 11-07-2007 04:58 AM
Oracle and JDBC Eric Database 3 08-11-2007 10:49 PM
oracle problem Peter Database 1 07-09-2007 06:19 AM
Oracle Driver softy Database 1 07-02-2007 02:20 AM


All times are GMT +3. The time now is 03:47 PM.


VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org