0

I am trying to persist a string object in Mysql(5.0.67) using hibernate.

My entity is as follows:

@Entity
@Table(name = "info", schema = "DB")
public class info {
@Column(name = "InfoXml")
private String InfoXml;
}

The problem is when I persist the xml with value:

String InfoXml = "<?xml version="1.0" encoding="UTF-8" standalone="no"?>\r\n<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">\r\n<properties>\r\n<entry key="Hello">hi</entry>\r\n</properties>";

The DB table column shows the only value as:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

being persisted.

Rest of the xml is disappearing without a trace.

Investigating little more I found that any string that is containing '\r\n' (next line) is being persisted till the next line only and the rest of the string is not persisted.

What's happening here? and what is the workaround?

Thanks in advance

Ashish

2 Answers 2

0

What is the column type is MySQL? If it's VARCHAR try using a TEXT type instead. I don't know MySQL that well but I would guess that it is the DB that is truncating the text, not hibernate.

0

Problem solved.

I was using Mysql GUI tools and it was not showing columns with multiple lines.

Checked the table data in mysql terminal and everything looks fine.

Thanks to those who responded promptly.

Ashish

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.