• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Insert row in a table which having No primary Key

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

Is there is any method in the hibernate for inserting many rows at a time.
The table is having no primaryKey Id
Thanks in advancejavascript: x()
rolling
 
Ranch Hand
Posts: 360
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wonder if it is even possible to have a table without primary key. I think it's not.

What would be the use of this table?
 
gopi nath
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI
In my case i want to store the Particular values in separate table,From that table i will generate reports without using PK , i will to sort by other fields
 
Pavel Kubal
Ranch Hand
Posts: 360
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I went through documentation and it really seems that you are not required to have a primary key. So I guess, that the mapping will be the same as usual, but without primary key.

And back to your question, have you heard of batch processing?

http://www.hibernate.org/hib_docs/reference/en/html/batch.html
 
gopi nath
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank You
Can you say is there is any method to save, without looping as mentioned by your reference document?
 
Pavel Kubal
Ranch Hand
Posts: 360
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You would like something like session.save(Collection c) ?

So, as far as I know, there is no such possibility.

http://simoes.org/docs/hibernate-2.1/api/net/sf/hibernate/Session.html
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"gopinath",
Welcome to the JavaRanch.

We're a friendly group, but we do require members to have valid display names.

Display names must be two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with display names get deleted.
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, it is possible to have a table w/o a primary key.
However, hibernate will use what you program in the id
(single field or composite).
As long as you code this in your equals method, you should be fine.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can set the generator of key to "native" ,
that is my suggestion,
i don't enure the method what i say can solve your problom.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bougnon Kipre:
Yes, it is possible to have a table w/o a primary key.
However, hibernate will use what you program in the id
(single field or composite).
As long as you code this in your equals method, you should be fine.



No, this is not the case. You might get away with it, but its not guarenteed to work.

It is possible to define an entity without a primary key in a relational database, but its not a smart thing to do. Without a primary key there is no way to identify a single row. If you can't identify a single row, it can't be used in a relationship, hence is not relational data. Because of this requirement Hibernate does not easily support tables without primary keys. There are work arounds (map all the fields in the the table as a composite key for example) but none are as easy as just giving your table a surrogate key.
 
There's a hole in the bucket, dear Liza, dear Liza, a hole in the bucket, dear liza, a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic