Estratégia 'tablePerHierarchy'
09/07/2010 00:00
0
Boa Tarde galera,

Eu estou começando no Grails e estou com problemas ao tentar setar o atributo tablePerHierarchy como false, vejam o código abaixo:

 static mapping = {
tablePerHierarchy false
observacao type:'text'
telefones lazy:false, fetch:"join", cascade:"all-delete-orphan"
emails lazy:false, fetch:"join", cascade:"all-delete-orphan"
meioDivulgacao lazy:false, fetch:"join", cascade:"none"
}


A minha estrutura de hierarquia é mais ou menos assim..
Contato -> Pessoa -> PessoaFisica -> ClientePessoaFisica
................................................-> PromotorPessoaFisica
................................................-> FornecedorPessoaFisica

..........................-> PessoaJuridica -> ClientePessoaJuridica
..................................................-> PromotorPessoaJuridica
..................................................-> FornecedorPessoaJuridica

A estratégia de criação das tabelas está definida na entidade 'Contato'

Só que quando eu vou rodar o projeto explode a seguinte exceção:

Error executing script TestApp: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: No discriminator found for carmo.ClientePessoaFisica. Discriminator is needed when 'single-table-per-hierarchy' is used and a class has subclasses
gant.TargetExecutionException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: No discriminator found for carmo.ClientePessoaFisica. Discriminator is needed when 'single-table-per-hierarchy' is used and a class has subclasses
at gant.Gant$_dispatch_closure4.doCall(Gant.groovy:331)
at gant.Gant$_dispatch_closure6.doCall(Gant.groovy:334)
at gant.Gant$_dispatch_closure6.doCall(Gant.groovy)
at gant.Gant.withBuildListeners(Gant.groovy:344)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:334)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.processTargets(Gant.groovy:495)
at gant.Gant.processTargets(Gant.groovy:480)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: No discriminator found for carmo.ClientePessoaFisica. Discriminator is needed when 'single-table-per-hierarchy' is used and a class has subclasses
at _GrailsBootstrap_groovy$_run_closure2_closure11.doCall(_GrailsBootstrap_groovy:89)
at _GrailsBootstrap_groovy$_run_closure2_closure11.doCall(_GrailsBootstrap_groovy)
at _GrailsSettings_groovy$_run_closure10.doCall(_GrailsSettings_groovy:282)
at _GrailsSettings_groovy$_run_closure10.call(_GrailsSettings_groovy)
at _GrailsBootstrap_groovy$_run_closure2.doCall(_GrailsBootstrap_groovy:79)
at _GrailsBootstrap_groovy$_run_closure6.doCall(_GrailsBootstrap_groovy:137)
at _GrailsTest_groovy$_run_closure9.doCall(_GrailsTest_groovy:309)
at _GrailsTest_groovy$_run_closure9.doCall(_GrailsTest_groovy)
at _GrailsTest_groovy$_run_closure1_closure21.doCall(_GrailsTest_groovy:193)
at _GrailsTest_groovy$_run_closure1.doCall(_GrailsTest_groovy:171)
at TestApp$_run_closure1.doCall(TestApp:102)
at gant.Gant$_dispatch_closure4.doCall(Gant.groovy:324)
... 10 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: No discriminator found for carmo.ClientePessoaFisica. Discriminator is needed when 'single-table-per-hierarchy' is used and a class has subclasses
... 22 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: No discriminator found for carmo.ClientePessoaFisica. Discriminator is needed when 'single-table-per-hierarchy' is used and a class has subclasses
... 22 more
Caused by: org.hibernate.MappingException: No discriminator found for carmo.ClientePessoaFisica. Discriminator is needed when 'single-table-per-hierarchy' is used and a class has subclasses
... 22 more
Error executing script TestApp: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: No discriminator found for carmo.ClientePessoaFisica. Discriminator is needed when 'single-table-per-hierarchy' is used and a class has subclasses


Por favor, quem puder me dar alguma luz de como resolver esse erro, fico muito agradecido.!

Obrigado!
Tags: Grails


0
Pessoal, deu certo.
Declarei a estratégia em todas as classes pais.
Eu achava que colocando apenas na classe mais alta.. as outras reconheceriam.!
valew. <!-- s:) --><img src="{SMILIES_PATH}/icon_smile.gif" alt=":)" title="Smile" /><!-- s:) -->
09/07/2010 00:00



Ainda não faz parte da comunidade???

Para se registrar, clique aqui.


Aprenda Groovy e Grails com a Formação itexto!

Newsletter Semana Groovy

Assinar

Envie seu link!


Livro de Grails


/dev/All

Os melhores blogs de TI (e em português) em um único lugar!

 
Creative Commons
RSS Grails Brasil é mantido por itexto Consultoria.
Em caso de problemas contacte Henrique Lobo Weissmann (Kico) por e-mail: kico@itexto.com.br
Todo o conteúdo presente neste site adota o Creative Commons como licença padrão.
Ver: 4.14.0
itexto