-->
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.  [ 6 posts ] 
Author Message
 Post subject: Turning off XML mapping
PostPosted: Mon Dec 12, 2005 6:40 am 
Newbie

Joined: Fri Nov 11, 2005 4:42 am
Posts: 17
Hello again - now that I finally have get/set XML functions working I have run into more problems!!

I don't believe the <any> or org.hibernate.type.AnyType can be set to XML!! I get -
java.lang.UnsupportedOperationException: any types cannot be stringified

which is a pain but I could live with that!!

BUT WHEN I TRY TO REMOVE THE <ANY> node mapping from my hbm files - nothing changes!

If I don't add the node tag to the mapping it should be ignored - I still get this error. I have tried removing the node tag from the set ie in Arrest mapping as well as remove the node tag from the any side ie Attachment. I have even removed all the node tags from the whole Attachment.hbm.xml file!!

Any help about how to either 'stingify' this type or get hibernate to ignore the association would be great.

Shane
ebersoless@yahoo.com


Hibernate version:
3.0.5

Mapping documents:
<class name="mil.ditv.model.Arrest"
table="ditv_arrest"
node="Arrest"
>
...
<!-- NO node tags -->
<set name="attachments"
cascade="all-delete-orphan">
<key column="parent_id"/>
<one-to-many
class="mil.ditv.model.Attachment"
node="attachment"
/>

</set>
</class>

<class name="mil.ditv.model.Attachment" table="ditv_attachment">
...
<any name="parent"
meta-type="java.lang.String"
id-type="java.lang.String" >
<meta-value value="ditv_arrest" class="mil.ditv.model.Arrest"/>
<column name="parent_type"/>
<column name="parent_id"/>
</any>

</class>


Code between sessionFactory.openSession() and session.close():
// test attachment
Attachment attachment = new Attachment();
attachment.setName("test");
arrest.addAttachment(attachment);
dao.save(packet);
dump(dao.getXML(id),"packet4.xml");

// getXML method
public Document getXML(final ID id) throws ObjectRetrievalFailureException
{
return (Document) getHibernateTemplate().execute(new HibernateCallback()
{
public Object doInHibernate(Session session)
{
session.flush();
session.clear();
Session dom4jSession = session.getSession(EntityMode.DOM4J);

Document document = DocumentFactory.getInstance().createDocument();

Element element = (Element)dom4jSession.get(modelClass, id);
document.add(element);
return document;
}
});
}

Full stack trace of any exception that occurs:

[junit] ------------- ---------------- ---------------
[junit] Testcase: testCRUD(mil.ditv.dao.PacketDAOTest): Caused an ERROR
[junit] any types cannot be stringified
[junit] java.lang.UnsupportedOperationException: any types cannot be stringi
fied
[junit] at org.hibernate.type.AnyType.setToXMLNode(AnyType.java:160)
[junit] at org.hibernate.property.Dom4jAccessor$ElementSetter.set(Dom4jA
ccessor.java:310)
[junit] at org.hibernate.tuple.AbstractEntityTuplizer.setPropertyValues(
AbstractEntityTuplizer.java:330)
[junit] at org.hibernate.persister.entity.AbstractEntityPersister.setPro
pertyValues(AbstractEntityPersister.java:3231)
[junit] at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLo
ad.java:126)
[junit] at org.hibernate.loader.Loader.initializeEntitiesAndCollections(
Loader.java:842)
[junit] at org.hibernate.loader.Loader.doQuery(Loader.java:717)
[junit] at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollec
tions(Loader.java:223)
[junit] at org.hibernate.loader.Loader.loadCollection(Loader.java:1916)
[junit] at org.hibernate.loader.collection.CollectionLoader.initialize(C
ollectionLoader.java:71)
[junit] at org.hibernate.persister.collection.AbstractCollectionPersiste
r.initialize(AbstractCollectionPersister.java:520)
[junit] at org.hibernate.event.def.DefaultInitializeCollectionEventListe
ner.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
[junit] at org.hibernate.impl.SessionImpl.initializeCollection(SessionIm
pl.java:1593)
[junit] at org.hibernate.type.CollectionType.getCollection(CollectionTyp
e.java:501)
[junit] at org.hibernate.type.CollectionType.resolveKey(CollectionType.j
ava:335)
[junit] at org.hibernate.type.CollectionType.resolve(CollectionType.java
:329)
[junit] at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLo
ad.java:113)
[junit] at org.hibernate.loader.Loader.initializeEntitiesAndCollections(
Loader.java:842)
[junit] at org.hibernate.loader.Loader.doQuery(Loader.java:717)
[junit] at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollec
tions(Loader.java:223)
[junit] at org.hibernate.loader.Loader.loadCollection(Loader.java:1916)
[junit] at org.hibernate.loader.collection.CollectionLoader.initialize(C
ollectionLoader.java:71)
[junit] at org.hibernate.persister.collection.AbstractCollectionPersiste
r.initialize(AbstractCollectionPersister.java:520)
[junit] at org.hibernate.event.def.DefaultInitializeCollectionEventListe
ner.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
[junit] at org.hibernate.impl.SessionImpl.initializeCollection(SessionIm
pl.java:1593)
[junit] at org.hibernate.type.CollectionType.getCollection(CollectionTyp
e.java:501)
[junit] at org.hibernate.type.CollectionType.resolveKey(CollectionType.j
ava:335)
[junit] at org.hibernate.type.CollectionType.resolve(CollectionType.java
:329)
[junit] at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLo
ad.java:113)
[junit] at org.hibernate.loader.Loader.initializeEntitiesAndCollections(
Loader.java:842)
[junit] at org.hibernate.loader.Loader.doQuery(Loader.java:717)
[junit] at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollec
tions(Loader.java:223)
[junit] at org.hibernate.loader.Loader.loadEntity(Loader.java:1782)
[junit] at org.hibernate.loader.entity.AbstractEntityLoader.load(Abstrac
tEntityLoader.java:93)
[junit] at org.hibernate.loader.entity.AbstractEntityLoader.load(Abstrac
tEntityLoader.java:81)
[junit] at org.hibernate.persister.entity.AbstractEntityPersister.load(A
bstractEntityPersister.java:2729)
[junit] at org.hibernate.event.def.DefaultLoadEventListener.loadFromData
source(DefaultLoadEventListener.java:365)
[junit] at org.hibernate.event.def.DefaultLoadEventListener.doLoad(Defau
ltLoadEventListener.java:346)
[junit] at org.hibernate.event.def.DefaultLoadEventListener.load(Default
LoadEventListener.java:123)
[junit] at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(
DefaultLoadEventListener.java:177)
[junit] at org.hibernate.event.def.DefaultLoadEventListener.onLoad(Defau
ltLoadEventListener.java:87)
[junit] at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:809)

[junit] at org.hibernate.impl.SessionImpl.get(SessionImpl.java:749)
[junit] at org.hibernate.impl.SessionImpl.get(SessionImpl.java:742)
[junit] at mil.ditv.dao.hibernate.BaseDAOHibernate$1.doInHibernate(BaseD
AOHibernate.java:139)
[junit] at org.springframework.orm.hibernate3.HibernateTemplate.execute(
HibernateTemplate.java:312)
[junit] at org.springframework.orm.hibernate3.HibernateTemplate.execute(
HibernateTemplate.java:288)
[junit] at mil.ditv.dao.hibernate.BaseDAOHibernate.getXML(BaseDAOHiberna
te.java:129)
[junit] at mil.ditv.dao.PacketDAOTest.testCRUD(PacketDAOTest.java:116)


[junit] Test mil.ditv.dao.PacketDAOTest FAILED

BUILD FAILED

Name and version of the database you are using:
MSSQL


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 12, 2005 6:58 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
if you want it ignored then don't map it.

e.g. create another mapping under a different entity-name

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: I don't have it mapped at all
PostPosted: Tue Dec 13, 2005 2:39 am 
Newbie

Joined: Fri Nov 11, 2005 4:42 am
Posts: 17
I have removed all xml node / entity mappings from the hbm file and still it gets mapped - I can't stop it.

Shane


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 13, 2005 2:55 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
i mean dont put the property in there at all...

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: how would I do this
PostPosted: Thu Dec 15, 2005 1:54 am 
Newbie

Joined: Fri Nov 11, 2005 4:42 am
Posts: 17
how would I do this? below is my mapping.

<hibernate-mapping>

<class name="mil.ditv.model.Attachment"
table="ditv_ATTACHMENT">

<id
name="id"
column="id"
type="java.lang.String"
length="50"
node="@id"
>
<generator class="guid">
</generator>
</id>


<version
name="version"
column="version"
type="java.lang.Integer"
node="@version"
/>

<property
name="name"
type="java.lang.String"
node="name"
/>


<any name="parent"
meta-type="java.lang.String"
id-type="java.lang.String" >
<meta-value value="ditv_arrest" class="mil.ditv.model.Arrest"/>
<column name="parent_type"/>
<column name="parent_id"/>
</any>

</class>

</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 15, 2005 2:35 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Code:
<hibernate-mapping>

<class name="mil.ditv.model.Attachment"
table="ditv_ATTACHMENT">

<id
name="id"
column="id"
type="java.lang.String"
length="50"
node="@id"
>
<generator class="guid">
</generator>
</id>

<version
name="version"
column="version"
type="java.lang.Integer"
node="@version"
/>

<property
name="name"
type="java.lang.String"
node="name"
/>

</class>
</hibernate-mapping>



problem solved ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.