-->
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: Extra garbage characters in TEXT MYSQL Columns from Hibernat
PostPosted: Thu Sep 22, 2005 9:04 pm 
Newbie

Joined: Thu Sep 22, 2005 8:39 pm
Posts: 2
We are using Hibernate 3 and MySQL 4.1. We have very simple table with ID_Key (INTEGER) and aText (TEXT). When we insert a row, and view the data from a database tool (MySQLManager) it appears that Hibernate is putting strange characters at the beginning of the TEXT column.

í t í t Text-1

The hex values of the characters in front of 'Text-1' are:

AC ED 00 05 74 00 06

We tried VarChars and it seemed to work fine. When hibernate reads the column, the return value is as expected. This is irritating when trying to read data directly without Hibernate. I was unable to find any hints online. Any guidance would be appreciated.

Thank you,

SearayCA

------------------------------------------------------------------------------------

import org.hibernate.Session;
import org.hibernate.Transaction;
import org.apache.commons.logging.*;;

public class Tester {

private static Log log = LogFactory.getLog(AMHSession.class);

void doIt()
{
Session s = AMHSession.currentSession();

Transaction tx = s.beginTransaction();

Testtable tt = new Testtable();
tt.setAvarchar128("VarChar128-2");
tt.setAvarchar255("VarChar255-2");
tt.setAtinytext("TinyText-2");
tt.setAtext("Text-2");
tt.setAmediumtext("MediumText-2");
tt.setAlongtext("LongText-2");

s.save(tt);
tx.commit();

AMHSession.closeSession();

}

public static void main(String[] args) {
System.out.println("Start");
Tester t = new Tester();
t.doIt();
System.out.println("Done");
}

}

------------------------------------------------------------------------------------

# EMS MySQL Manager Pro 3.3.0.2
# ---------------------------------------
# Host : localhost
# Port : 3306
# Database : htest


SET FOREIGN_KEY_CHECKS=0;

CREATE DATABASE `htest`
CHARACTER SET 'latin1'
COLLATE 'latin1_swedish_ci';

USE `htest`;

#
# Structure for the `testtable` table :
#

CREATE TABLE `testtable` (
`ID_Key` int(11) NOT NULL auto_increment,
`aVarChar128` varchar(128) default NULL,
`aVarChar255` varchar(255) default NULL,
`aText` text,
`aTinyText` tinytext,
`aMediumText` mediumtext,
`aLongText` longtext,
PRIMARY KEY (`ID_Key`),
UNIQUE KEY `ID_Key` (`ID_Key`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

#
# Data for the `testtable` table (LIMIT 0,500)
#

INSERT INTO `testtable` (`ID_Key`, `aVarChar128`, `aVarChar255`, `aText`, `aTinyText`, `aMediumText`, `aLongText`) VALUES
(1,'VarChar128-1','VarChar255-1','’\0t\0Text-1','TinyText-1','’\0t\0 MediumText-1','’\0t\0\nLongText-1');

COMMIT;


Top
 Profile  
 
 Post subject: problem caused by MyEclipseIDE
PostPosted: Fri Sep 23, 2005 7:20 pm 
Newbie

Joined: Thu Sep 22, 2005 8:39 pm
Posts: 2
We have been having a problem with Hibernate. It seems to be placing some garbage characters in the TEXT type columns. It appears that MyEclipseIDE Hibernate mapper does the wrong thing for type TEXT. It uses type ="serializable" instead of type="string" . Make sure all TEXT type fields are mapped to string.

Code:
<hibernate-mapping>

    <class name="Testtable" table="testtable">
        <id name="idKey" column="ID_Key" type="integer">
            <generator class="increment"/>
        </id>

// NOT THIS ONE
//    <property name="atext" column="aText" type="serializable" />

// THIS ONE
       <property name="atext" column="aText" type="string" />

    </class>
   
</hibernate-mapping>


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.