-->
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.  [ 1 post ] 
Author Message
 Post subject: Hibernate - Stored Procedure and Mapping
PostPosted: Mon Oct 08, 2007 8:41 am 
Newbie

Joined: Mon Oct 08, 2007 8:21 am
Posts: 3
Hi There!

I'm facing problems with my web-app using hibernate.

I have a stored procedure in my database that returns me a table.

the fields are coditabe, inclaces, alteaces, consaces, exclaces

the question is... how do I do to map this one?

I have read that it's on this way:

Code:
<sql-query name="POVIACES" callable="true">
        <return alias="emp" class="Poviaces">
            <return-property name="id" column="CODITABE"/>
            <return-property name="inclaces" column="INCLACES"/>
            <return-property name="alteaces" column="ALTEACES"/>
            <return-property name="consaces" column="CONSACES"/>
            <return-property name="exclaces" column="EXCLACES"/>
        </return>
        { ? = call POVIACES() }
    </sql-query>



my class is:

Code:
public class Poviaces implements java.io.Serializable  {

//campos
private long id; 
private boolean inclaces;
private boolean alteaces;
private boolean consaces;
private boolean exclaces;


    public Poviaces() {
    }
    /** minimal constructor */
    public Poviaces(long coditabe) {
        this.id = coditabe;
    }

    public void setInclaces(boolean inclaces) {
        this.inclaces = inclaces;
    }

    public boolean isInclaces() {
        return inclaces;
    }

    public void setAlteaces(boolean alteaces) {
        this.alteaces = alteaces;
    }

    public boolean isAlteaces() {
        return alteaces;
    }

    public void setConsaces(boolean consaces) {
        this.consaces = consaces;
    }

    public boolean isConsaces() {
        return consaces;
    }

    public void setExclaces(boolean exclaces) {
        this.exclaces = exclaces;
    }

    public boolean isExclaces() {
        return exclaces;
    }

    public void setId(long id) {
        this.id = id;
    }

    public long getId() {
        return id;
    }
}



to obtain one object from class poviaces I call

[code Session s = (isSessionSuplied() ? getSession() : getNewSession());
try {
List list =
s.createSQLQuery("SELECT * FROM POVIACES WHERE CODITABE = " + tabe.getCoditabe() + ""). list();
if (list.size() > 0) {
return (Poviaces)list.get(0);
} else {
return null;
}
} catch (HibernateException hex) {
hex.printStackTrace();
throw hex;
} finally {
if (!isSessionSuplied()) {
s.close();
}
}
} [/code]



ok...
till then, I get one result in my list as I expected. but in the return, it returns me a null object, a null Poviaces...
why???


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

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.