Reputation: 129
I have domain class,in which I am declaring id as string and in mapping id is mapped to ROWID.I do not want that id to take part in insert operation. But,while persisting through domain,I am getting the error like : null id in com.bt.viewer.TCircuitDetails entry Can anybody help regarding:do I need to mention database column for id? In gorm query that insertion sql is generating hibernate sequence for id,which I can not use for any of the column.
I can assign id to one primary key column which is there in database,but id is taking only hibernate sequence,so I can not map id to any of the column.I can not alter table with addition of new column to accomodate id value.
What is the solution.Please help
Thanks..
Upvotes: 1
Views: 682
Reputation: 2931
You need to override Hibernate's default identity generator - here is the relevant chapter in the Grails documentation which basically points you to Hibernate documentation.
From what I gather you would need to implement a custom IdentifierGenerator
similarly to how this person did it for their project.
I don't know why you are trying to define your own IDs but perhaps the following simpler solution would work for you as well: let Grails/Hibernate store its ID into another column (say hibernate_id
) and then you can use id
for your own purposes by inserting id column: 'hibernate_id'
into the mapping
block (see the link to Grails documentation). You would need to use DomainClass.findById()
instead of DomainClass.get()
everywhere, though.
Upvotes: 1