-->
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.  [ 7 posts ] 
Author Message
 Post subject: Inserting a row in a table with no primary/secondary key
PostPosted: Sun Jul 10, 2005 7:36 pm 
Newbie

Joined: Mon Mar 07, 2005 7:18 pm
Posts: 16
Friends,

can someone tell me how to map a table with no primary/secondary key. I've a log table in which I need to insert a log entry for every activity.

Thanks for your time,
Ram N.


Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 11, 2005 12:45 am 
Beginner
Beginner

Joined: Fri Jul 08, 2005 12:38 pm
Posts: 41
Location: Massachusetts, USA
I assume your log table will have a timestamp column (what log doesn't?). Can you use that column as the ID/primary key, or many a composite-id of the timestamp and something else (like a threadId)?

It would be best if you add an ID column to the table. Of course if this is a legacy system it may be out of your control.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 11, 2005 12:00 pm 
Newbie

Joined: Mon Mar 07, 2005 7:18 pm
Posts: 16
Does Hibernate support key less table insert? just curious to know.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 11, 2005 1:06 pm 
Beginner
Beginner

Joined: Thu Jul 07, 2005 7:12 pm
Posts: 25
chicagoram wrote:
Does Hibernate support key less table insert? just curious to know.


Not really. You can define a composite key with all columns as a last resort though.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 11, 2005 1:33 pm 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
To quote Hibernate in Action:
Quote:
[...]
You need a primary key for a table to work with Hibernate; otherwise there is no
way to distinguish rows. This is true not only for Hibernate but for every other
system (and user) of your database. We recommend that you clean up the database.
As a last resort, you can use a composite key mapping in Hibernate and
include all columns as a composite key.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 11, 2005 1:54 pm 
Newbie

Joined: Mon Mar 07, 2005 7:18 pm
Posts: 16
Thanks guys. Appreciate your time


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 12, 2005 5:21 am 
Newbie

Joined: Tue Jul 12, 2005 5:17 am
Posts: 9
jweiskotten wrote:
I assume your log table will have a timestamp column (what log doesn't?). Can you use that column as the ID/primary key [...]


Exact. A timestamp column with sysdate (oracle) default value.
But what kind of id generator I should use ?
I have an IdentifierGenerationException wiathout any generator.


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