I have a class with a property:
virtual public string Data { get; set; }
example.hbm.xml binds that to:
<property name="Data" type="string" column="data" ></property>
The table in MySql is created with:
CREATE TABLE `xxx` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`data` blob,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=binary;
I can successfully write to the db and I can see the text in the column written properly.
When I try to read records from this table the value of the 'Data' property is 'System.Byte[]'. Again this is the value of this property. It's type is 'System.String'.
What to do? Thanks in advance for any clues.
I tried charset=UTF8 too.
I also tried type="StringClob" in the mapping file.
Thanks Tymek
You probably need to read and write this as a byte[]. So you're property definition would look like this instead:
public virtual byte[] Data { get; set; }
In addition to this change you will need to change the type in your mapping. I'm not sure what the type. I think it may be blob.
You can easily convert this data to a string if you need to.
I'm no MySQL expert, but you probably want the column type to be text
instead of blob
.
With that, type="StringClob"
should work
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.