Hi.
Perhaps this isn't directly related to Hibernate, but it only happens with @Lobs, so I figured I might get some hints here.
I've got a @Lob String property and when I set the string to something with Swedish charracters "åäö", the String is truncated, starting from the first "å".
Hibernate version: 3.1 and annotations 3.1 beta 8
Database: MySQL 5.0.18 (InnoDB)
You can reproduce it with this code:
Code:
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.AnnotationConfiguration;
public class Test
{
public static void main(String argv[])
{
AnnotationConfiguration c = new AnnotationConfiguration();
c.addAnnotatedClass(Foo.class);
SessionFactory sf = c.buildSessionFactory();
Foo foo = new Foo();
foo.bar = "abc, åäö, xyz";
Session session = sf.openSession();
Transaction tx = session.beginTransaction();
session.save(foo);
tx.commit();
session.close();
}
@Entity
public static class Foo
{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Long id;
@Lob
public String bar;
}
}
Generated SQL: (seems ok)
From the SQL server log:
Code:
912 Query SET NAMES latin1
912 Query SET character_set_results = NULL
912 Query SHOW VARIABLES
912 Query SHOW COLLATION
912 Query SET autocommit=1
912 Query SET autocommit=0
912 Query SHOW VARIABLES LIKE 'tx_isolation'
912 Prepare [1]
912 Query SHOW CHARACTER SET
912 Execute [1] insert into Test$Foo (bar) values ('abc, åäö, xyz')
912 Query commit
But when I check the db afterwards, åäö are gone:
Code:
mysql> SELECT * from Test$Foo;
+----+-------+
| id | bar |
+----+-------+
| 1 | abc, |
+----+-------+
1 row in set (0.00 sec)