-->
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.  [ 3 posts ] 
Author Message
 Post subject: Hibernate fails to load values from DB into a Bean
PostPosted: Mon Oct 17, 2005 2:53 pm 
Beginner
Beginner

Joined: Tue Jul 19, 2005 1:24 pm
Posts: 22
Hi All,

I am loading a DB record via Hibernate using this:

Person person = (Person) session.load(Person.class,5667);

and then trying to output the Person Bean into an XML format using Apache Commons Betwixt like this:

Main Class:
Code:

BeanWriter beanWriter;
StringWriter outputWriter;

       //THIS IS HOW I CONFIGURE BETWIXT TO GET MY DESIRED XML OUTPUT

        outputWriter = new StringWriter();
        // For well-formed xml, we need to add the prolog
        outputWriter.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
   
        // Create a BeanWriter which writes to our prepared stream
        beanWriter = new BeanWriter(outputWriter);
     
        //Tweaked configuration for getting desired XML o/p    for XML SearchResponse                   
        beanWriter.getXMLIntrospector().getConfiguration().setWrapCollectionsInElement(false);
        beanWriter.getBindingConfiguration().setMapIDs(true);
        beanWriter.enablePrettyPrint();


beanWriter.write("perspectiveResponse", new PerspectiveResponse(person));
System.out.println( outputWriter.toString());



But when I run my Main class it gives me an error:

java.lang.UnsupportedOperationException
at org.hibernate.util.IdentityMap.keySet(IdentityMap.java:162)
at org.hibernate.stat.SessionStatisticsImpl.getEntityCount(SessionStatisticsImpl.java:21)
at org.hibernate.stat.SessionStatisticsImpl.toString(SessionStatisticsImpl.java:37)
at java.lang.String.valueOf(String.java:2577)
at java.lang.StringBuffer.append(StringBuffer.java:220)
at org.apache.commons.betwixt.io.AbstractBeanWriter.pushBean(AbstractBeanWriter.java:1019)
at org.apache.commons.betwixt.io.AbstractBeanWriter.writeBean(AbstractBeanWriter.java:348)
at org.apache.commons.betwixt.io.AbstractBeanWriter.writeBean(AbstractBeanWriter.java:267)
at org.apache.commons.betwixt.io.AbstractBeanWriter.writeElementContent(AbstractBeanWriter.java:945)
at org.apache.commons.betwixt.io.AbstractBeanWriter.writeElement(AbstractBeanWriter.java:820)
at org.apache.commons.betwixt.io.AbstractBeanWriter.writeBean(AbstractBeanWriter.java:362)
at org.apache.commons.betwixt.io.AbstractBeanWriter.writeBean(AbstractBeanWriter.java:267)
at org.apache.commons.betwixt.io.AbstractBeanWriter.writeElementContent(AbstractBeanWriter.java:945)
at org.apache.commons.betwixt.io.AbstractBeanWriter.writeElement(AbstractBeanWriter.java:820)
at org.apache.commons.betwixt.io.AbstractBeanWriter.writeBean(AbstractBeanWriter.java:362)
at org.apache.commons.betwixt.io.AbstractBeanWriter.writeBean(AbstractBeanWriter.java:267)
at org.apache.commons.betwixt.io.AbstractBeanWriter.writeElementContent(AbstractBeanWriter.java:936)
at org.apache.commons.betwixt.io.AbstractBeanWriter.writeElement(AbstractBeanWriter.java:820)
at org.apache.commons.betwixt.io.AbstractBeanWriter.writeBean(AbstractBeanWriter.java:362)
at org.apache.commons.betwixt.io.AbstractBeanWriter.writeBean(AbstractBeanWriter.java:243)
at org.apache.commons.betwixt.io.AbstractBeanWriter.write(AbstractBeanWriter.java:174)
at com.mms.HibernateTest.main(HibernateTest.java:74)


I am not sure why Hibernate is throwing me this error. Has anybody worked on the combination of Hibernate and Betwixt before ??? ( I mean loading a Bean with Hibernate and outputing it via Betwixt)

Did anyone come across through this problem?

All help and suggestions are greatly appreciate !!!

Thanks
Sam


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 17, 2005 2:55 pm 
Beginner
Beginner

Joined: Tue Jul 19, 2005 1:24 pm
Posts: 22
FYI this is how my PerspectiveResponse Bean looks like:


Code:
public class PerspectiveResponse {
    private Object object;
   
    public PerspectiveResponse() {
       
    }
    public PerspectiveResponse(Object object) {
        setObject(object);
    }
   
   
    public Object getObject() {
        return this.object;
    }
    public void setObject(Object object) {
        this.object = object;
    }

}


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 17, 2005 3:53 pm 
Beginner
Beginner

Joined: Tue Jul 19, 2005 1:24 pm
Posts: 22
I got this working, was just supposed to include laszy="false" in my mapping file ....


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