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\0MediumText-1','’\0t\0\nLongText-1');
COMMIT;
|