-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Problems with <any> and association classes
PostPosted: Mon Aug 30, 2004 12:51 am 
Beginner
Beginner

Joined: Sun Feb 08, 2004 4:09 pm
Posts: 46
Hi,

I'm trying to implement multiple inheritance with <any>.

I understand how to use it. But my problem is that there's an association class called HabilitacaoBean that refers to a "any" object, and it's FK should be primary making a composed primary key with another one. But hibernate throws this exception and I don't know where update="false" and insert="false" should go....

Thanks in advance.


Hibernate version:
2.1.6

Mapping documents:
<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
<class
name="br.com.ejconsultoria.business.beans.HabilitacaoBean"
table="HABILITACAO"
dynamic-update="false"
dynamic-insert="false"
>

<composite-id
name="oid"
class="br.com.ejconsultoria.business.beans.HabilitacaoBeanPK"
>
<key-property
name="oidPrestador"
type="string"
column="oid_pessoa"
length="32"
/>

<key-property
name="oidServico"
type="string"
column="oid_servico"
length="32"
/>

</composite-id>

<many-to-one
name="grau"
class="br.com.ejconsultoria.business.beans.TipoGrauBean"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="oid_grau"
not-null="true"
/>

<many-to-one
name="servico"
class="br.com.ejconsultoria.business.beans.ServicoBean"
cascade="none"
outer-join="auto"
update="false"
insert="false"
access="property"
column="oid_servico"
not-null="true"
/>

<any name="prestador"
meta-type="string"
id-type="string"
cascade="none">

<meta-value value="PPF" class="br.com.ejconsultoria.business.beans.PrestadorPessoaFisicaBean"/>
<meta-value value="PPJ" class="br.com.ejconsultoria.business.beans.PrestadorPessoaJuridicaBean"/>
<column name="subclass_prestador"/>
<column name="oid_pessoa"/>
</any>

</class>

</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
try
{
Criteria criteria = currentSession().createCriteria(HabilitacaoBean.class);

return criteria.list();


} catch (Exception e)
{

e.printStackTrace();

return null;

}

Full stack trace of any exception that occurs:
01:35:59,375 INFO [STDOUT] net.sf.hibernate.LazyInitializationException: Hibernate lazy instantiation problem
at net.sf.hibernate.jmx.SessionFactoryStub.getImpl(SessionFactoryStub.java:77)
at net.sf.hibernate.jmx.SessionFactoryStub.openSession(SessionFactoryStub.java:62)
at br.com.ejconsultoria.framework.dataservice.Database.currentSession(Database.java:127)
at br.com.ejconsultoria.framework.dataservice.Database.load(Database.java:64)
at br.com.ejconsultoria.framework.devutil.DatabaseLoader.init(DatabaseLoader.java:76)
at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:839)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:332)
at javax.servlet.GenericServlet.init(GenericServlet.java:211)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1019)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:687)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:144)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:72)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.invoke(JBossSecurityMgrRealm.java:275)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)
Caused by: net.sf.hibernate.MappingException: Repeated column in mapping for class br.com.ejconsultoria.business.beans.HabilitacaoBean should be mapped with insert="false" update="false": oid_pessoa
at net.sf.hibernate.persister.AbstractEntityPersister.checkColumnDuplication(AbstractEntityPersister.java:1002)
at net.sf.hibernate.persister.EntityPersister.<init>(EntityPersister.java:821)
at net.sf.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:42)
at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:137)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:768)
at net.sf.hibernate.jmx.HibernateService.buildSessionFactory(HibernateService.java:176)
at net.sf.hibernate.jmx.SessionFactoryStub.getImpl(SessionFactoryStub.java:74)
... 35 more
Name and version of the database you are using:
Latest MySQL

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 30, 2004 5:20 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Ooops, you need to edit the hibernate mapping DTD to allow insert/update attributes on the <any> element.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 30, 2004 1:38 pm 
Beginner
Beginner

Joined: Sun Feb 08, 2004 4:09 pm
Posts: 46
Would it be something like:

<!ELEMENT any (meta*,meta-value*,column,column+)>
<!ATTLIST any id-type CDATA #REQUIRED>
<!ATTLIST any meta-type CDATA #IMPLIED> <!--- default: Hibernate.CLASS -->
<!ATTLIST any name CDATA #REQUIRED>
<!ATTLIST any access CDATA #IMPLIED>
<!ATTLIST any insert (true|false) #IMPLIED>
<!ATTLIST any update (true|false) #IMPLIED>
<!ATTLIST any cascade (none|save-update|all) "none">
<!ATTLIST any index CDATA #IMPLIED> <!-- include the columns spanned by this association in an index -->

If so, will hibernate understand this mapping???


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 31, 2004 11:41 am 
Beginner
Beginner

Joined: Sun Feb 08, 2004 4:09 pm
Posts: 46
If this is the solution (couldn't test yet), please consider changing http://hibernate.sourceforge.net/hibern ... ng-2.0.dtd cause I'm generating the mappings through xdoclet, and It doesn't have an option to point to another dtd...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.