-->
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.  [ 2 posts ] 
Author Message
 Post subject: Mapping a char
PostPosted: Wed Sep 27, 2006 12:55 pm 
Newbie

Joined: Tue Aug 01, 2006 12:58 pm
Posts: 6
Dear guys,
I'm getting mad with this problem.

I already have a table on db2 with data in it. Now I made up an hibernate mapping to manage my data on db with Hibernate.

The table is:

Code:
CREATE TABLE MESSAGES
(
   MESSAGE_ID INTEGER PRIMARY KEY not null,
   ASK_INFO_MAIL VARCHAR(50),
   FROM_DATE DATE,
   TO_DATE DATE,
   UPDATE_DATE TIMESTAMP,
   UPDATE_USERID VARCHAR(50) not null,
   ASK_INFO CHAR(1) not null,
   INDUSTRY_ID INTEGER
);


So my mapping would be

Code:
<class name="com.package.Message" table="MESSAGES">
<id name="messageId" type="int" unsaved-value="0" >
   <column name="MESSAGE_ID" sql-type="int" not-null="true"/>
   <generator class="sequence"><param name="sequence">MSG_ID</param></generator>
</id>

<property name="askInfoMail">
    <column name="ASK_INFO_MAIL" sql-type="varchar(50)"/>
</property>
<property name="fromDate">
    <column name="FROM_DATE" sql-type="date" />
</property>
<property name="toDate">
    <column name="TO_DATE" sql-type="date" />
</property>
<property name="updateDate">
    <column name="UPDATE_DATE" sql-type="timestamp" />
</property>
<property name="updateUser">
    <column name="UPDATE_USERID" sql-type="varchar(50)" />
</property>
<property name="askInfo">
    <column name="ASK_INFO" not-null="true" sql-type="char(1)"/>
</property>
....

</class>
</hibernate-mapping>


And my class would have method like ...

Code:
    private char askInfo = 'N';

    public char getAskInfo() {
        return askInfo;
    }
    public boolean isAskInfo() {
        return (askInfo == 'Y');
    }
    public void setAskInfo(char askInfo) {
        this.askInfo = askInfo;
    }


Ok, when I try getting data from db, everytime I get this error:

org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of com.package.Message.askInfo

I tried modifing the mapping file without putting the sql-type="char(1)", then using Character in class instead of char, then String.
I always get the same error message.

Do you have any idea??
How would I know what kind of object Hibernate is trying to set?

Thanks a lot in advance!!

MDC


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 27, 2006 1:16 pm 
Newbie

Joined: Tue Sep 19, 2006 7:07 pm
Posts: 9
Try to use in the map file

type="java.lang.Character"

It works to me.


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