These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Empty GUIDs stored into the database
PostPosted: Sun Oct 11, 2009 1:18 pm 
Newbie

Joined: Sun Oct 11, 2009 1:08 pm
Posts: 1
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.