开发者

problem persisting xml in Mysql using hibernate

开发者 https://www.devze.com 2022-12-14 16:00 出处:网络
I am trying to persist a string object in Mysql(5.0.67) using hibernate. My entity is as follows: @Entity

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


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消