Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mapping for Table without Primary Key

 
Ramprasad Subburaman
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • 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
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks for your quick reply.

I kindly request you to provide exact mapping for above mentioned table structure.
 
Sebastian Hennebrueder
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read about join in the Hibernate Reference.

Best Regards

Sebastian
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic