Hello,
I'm currently building a NHibernate-based application to implement the LMTP protocol.
I use MySQL 5, and I had to implement MySQL5InnoDBDialect.cs from the Java equivalent to support transactions.
I chose to use System.Guid as identifier for email messages to store.
However, when I enter the new object into the database, I always find (with MySQL Administrator) the ID empty, so when I try to insert the second object I get a "duplicate entry error".
The problem happens only during SQL insertion, because the generated GUID is visible from an EventHandler class I use to store the body of the message onto disk (so file "abcde-[...]-12345.mail" is saved).
I tried to look deeply into it using Wireshark to sniff traffic, and it "seems" that NHibernate tries to insert the GUID value as binary
I had the same problem even before reimplementing MySQL5InnoDBDialect (in fact I had to implement it to preserve consistency when transactions were aborted as default dialect only uses MyISAM engine).
Can you help me? Mapping follows
Code:
<class name="MailMessage">
<id name="Id" type="Guid" unsaved-value="null">
<generator class="guid" />
</id>
<property name="Subject" type="string" not-null="false" />
<property name="Sender" type="string" not-null="true" />
<property name="AlreadyRead" type="bool" not-null="true" index="idxRead" />
<property name="Received" type="DateTime" not-null="true" insert="true" update="false" index="idx_ReceivedOrder" />
<many-to-one cascade="delete" class="Mailbox" not-found="exception" outer-join="auto"
foreign-key="FK_mailbox" name="Recipient" not-null="true" index="idx_Mailbox" />
</class>
By the way, I forgot to tell you the real "sympthoms": I just can't retrieve any value from DB because NHIbernate will raise an exception when trying to supply the Didentifier from DB to the constructor of System.Guid.