Quantcast

tablePerHierarchy false broken?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

tablePerHierarchy false broken?

Daniel Glauser
Hello folks,

Having issues with tablePerHierarchy false in Grails 2.0.  Specifically grails-2.0.0.RC1.  Any thoughts?  Yes, my base class is abstract and I've defined:

static mapping = {
    tablePerHierarchy false
}

In fact, here's my entire base class:

abstract class BaseDomain {
        String guid
        Date dateCreated
        Date lastUpdated
       
  static constraints = {
    guid(nullable:true, size:36..72)
    dateCreated(nullable:true)
    lastUpdated(nullable:true)
  }
 
  static mapping = {
                tablePerHierarchy false
        }
       
        transient def beforeInsert = {
    // Allow the subclass to provide the guid if necessary
                if(!guid) guid = java.util.UUID.randomUUID().toString()
        }
}

I keep seeing a base_domain table in the db.  We definitely don't want every query joining to the same table.  Using mysql  Ver 14.14 Distrib 5.5.14.  Any thoughts would be appreciated.

Thanks,
Daniel

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: tablePerHierarchy false broken?

Gaurav Chauhan-2
Abstract class behave differently in Grails 2.0

Please take a look at http://grails.org/doc/2.0.0.RC1/guide/gettingStarted.html (Look for Abstract Inheritance Changes)

Hope it helps.

Regards
Gaurav Chauhan



On Mon, Nov 7, 2011 at 2:07 AM, Daniel Glauser <[hidden email]> wrote:
Hello folks,

Having issues with tablePerHierarchy false in Grails 2.0.  Specifically
grails-2.0.0.RC1.  Any thoughts?  Yes, my base class is abstract and I've
defined:

static mapping = {
   tablePerHierarchy false
}

In fact, here's my entire base class:

abstract class BaseDomain {
       String guid
       Date dateCreated
       Date lastUpdated

 static constraints = {
   guid(nullable:true, size:36..72)
   dateCreated(nullable:true)
   lastUpdated(nullable:true)
 }

 static mapping = {
               tablePerHierarchy false
       }

       transient def beforeInsert = {
   // Allow the subclass to provide the guid if necessary
               if(!guid) guid = java.util.UUID.randomUUID().toString()
       }
}

I keep seeing a base_domain table in the db.  We definitely don't want every
query joining to the same table.  Using mysql  Ver 14.14 Distrib 5.5.14.
Any thoughts would be appreciated.

Thanks,
Daniel



--
View this message in context: http://grails.1312388.n4.nabble.com/tablePerHierarchy-false-broken-tp3996671p3996671.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: tablePerHierarchy false broken?

Daniel Glauser
Hello Gaurav,

Thanks for the reply, that definitely helps to understand why tablePerHierarchy doesn't work anymore.  What I'd like to understand is why this change was made?  Although I can put data in one place constraints and beforeInstert {...} closures no longer work when I move the base domain class to the src/groovy folder.  Is there some other way I can put this functionality in one place?  I have a lot of respect for the folks behind Grails but it sure feels like this change is a big step backwards.

Thanks,
Daniel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: tablePerHierarchy false broken?

Gaurav Chauhan-2
Hi Daniel,

Well i have no idea why it was implemented. I get to know about this while listening the latest podcast and people suggested the same alternative of moving abstract classes from domain to src/groovy.

Even i am curious know what benefits does it brings to the table?

Regards
Gaurav Chauhan



On Wed, Nov 9, 2011 at 6:49 AM, Daniel Glauser <[hidden email]> wrote:
Hello Gaurav,

Thanks for the reply, that definitely helps to understand why
tablePerHierarchy doesn't work anymore.  What I'd like to understand is why
this change was made?  Although I can put data in one place constraints and
beforeInstert {...} closures no longer work when I move the base domain
class to the src/groovy folder.  Is there some other way I can put this
functionality in one place?  I have a lot of respect for the folks behind
Grails but it sure feels like this change is a big step backwards.

Thanks,
Daniel

--
View this message in context: http://grails.1312388.n4.nabble.com/tablePerHierarchy-false-broken-tp3996671p4018271.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Loading...