Say I have something like:
class Foo {
static mapping = {
table 'foo_table'
}
}
How can I get the name of foo_table
if I have a reference to an instance of this object?
Import org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder
.
To get the table name from the domain class:
def tableName = GrailsDomainBinder.getMapping(Foo).table.name
And to get the table name from an instance of the domain class:
def tableName = GrailsDomainBinder.getMapping(foo.class).table.name
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With