satshil opened a new issue, #14643:
URL: https://github.com/apache/grails-core/issues/14643
# Problem
Table Per subclass not working if parent is abstract class
# Scenario
I have created following hierarchy of domain classes
Grails 3.0.10
JVM 1.7
abstract class Image(){
String name
String path
mapping:{
tablePerHierarchy false
id column: "image_id"
}
}
class userImage extends Image(){
User user
static belongsTo:[User]
mapping:{
id column: "image_id"
}
}
class itemImage extends Image(){
Item item
static belongsTo:[Item]
mapping:{
id column: "image_id"
}
}
class User(){
String name
static hasMany:[images:UserImage]
}
class Item(){
String name
static hasMany:[images:ItemImage]
}
Bootstrap.groovy
Item itm = new Item()
itm.name = "item name"
ItemImage img = new ItemImage()
img.name = "img name"
img.path = "dummy path"
itm.addToImages(img)
itm.save(flush:true)
// successfully saved the record in 3 tables
item
item_mage
image
def newItem = item.get(itm.id) // pass newly created id
def images = item.images
ERROR : column image_0.class not found.
#
If i try to define images as type of Image it gives problem at insert, as
follows
- It restricts me to define itemImages id key as column "item_image_id"
- It try to insert into item_image twice
- When I look in to table I found there are two foreign keys created one as
image and another for images
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]