0

I'm making a Grails application using GORM and as the title says I've come across a table that doesn't contain a primary key that I need to map in my domain. I know it requires an ID but in this case what can I do to get around it? I've searched and searched but haven't found an answer.

Regards,

Jamie

Joshua Moore
  • 24,706
  • 6
  • 50
  • 73
Jamie
  • 73
  • 1
  • 13

1 Answers1

0

Ideally you should always have a primary key in your table.

If for some reason it's completely impossible to create one, I've seen in the Grails documentation that they allow composite identifiers. They don't recommend it, though, and I've never been forced to do it so proceed at your own risk!

Derek
  • 132
  • 1
  • 5
  • 1
    I'll find out if it's a possibility to add a PK to the table on Monday as it's a work related project. Composite ID's wouldn't work in this case unfortunately either. – Jamie Aug 01 '14 at 14:58
  • Sounds like one jacked up table definitely in need of a PK! – Derek Aug 01 '14 at 15:10
  • Ok so I'm trying to use each column (5 of them) to make up a composite key and I'm getting the following error. – Jamie Aug 04 '14 at 12:53
  • These comment boxes aren't large enough for me to paste the error into? What other option do I have? – Jamie Aug 05 '14 at 08:13