• 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

Mapping for Table without Primary Key

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I kindly request you to give a best solution to this problem.

Table1 { column1, column2, column3 } no primary key.

Two SQL used are
1) select distinct column1, column2 from table1
2) select distinct column2, column3 from table1

If I map column1 and column2 as composite id , I get error on displaying the result of second SQL in the JSP.(${table1.column3} The "." operator was supplied with an index value of type "java.lang.String" to be applied to a List or array, but that value cannot be converted to an integer)
and vice-versa.

I kindly request you to give a best solution for this.

Thanks in advance,
Ramprasad
 
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
The only real solution is to fix your broken data model. An entity that does not have a primary key is not relational data, so you can't expect an ORM product to be able to know how to handle it. You don't say which ORM product you are using but the workaround in Hibernate could be to to create a composite key including every field in the table. Alternatively, give your table a surrogate key.
 
Ramprasad Subburaman
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your quick reply.

I kindly request you to provide exact mapping for above mentioned table structure.
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Read about join in the Hibernate Reference.

Best Regards

Sebastian
 
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

Originally posted by Sebastian Hennebrueder:
Read about join in the Hibernate Reference.

Best Regards

Sebastian



join? As is joining two tables, inner/outer joins? But doesn't he have only one table? I am a little confused.


I kindly request you to provide exact mapping for above mentioned table structure.



Now, we can't exactly do all your work for you. How would you start?

Mark
 
Sebastian Hennebrueder
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Mark,

Join element to specify a query how to get the data.

But still a primay key will be needed.

Regards Sebastian
 
Could you hold this kitten for a sec? I need to adjust this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic