-->
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.  [ 2 posts ] 
Author Message
 Post subject: Empty guid inserted in table
PostPosted: Mon Mar 16, 2009 9:40 pm 
Newbie

Joined: Mon Mar 16, 2009 9:24 pm
Posts: 2
Location: Australia
Hi,

I am using an existing database, so I can't make significant changes to it.

THis is the User.hbm.xml file:

Code:
[i]<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
  <class name="Infobase.Core.Domain.User, ePos.Core" table="TLPOSAddressLoginIDs">
    <id name="LoginUid" column="EntryTLPOSAddressLoginID" type="Int32" >
      <generator class="native" />
    </id>
    <many-to-one name="Details"
                 class="Infobase.Core.Domain.UserDetails, ePos.Core"
                 column="UniqueTLPOSAddress"
                 cascade="all" unique="true"/>
  </class>
  <class name="Infobase.Core.Domain.UserDetails, ePos.Core" table="TLPOSAddresses" dynamic-update="true">
    <id name="Id" column="UniqueTLPOSAddress" type="Guid" >
      <generator class="guid"></generator>
    </id>
  </class>
</hibernate-mapping>[/i]

Got my classes like this (made shorter to ommit irrelevant fields):

Code:
public class User {
    private int loginUid;
    private UserDetails details;

    public virtual int LoginUid {
        get { return loginUid; }
        set { loginUid = value; }
    }
   
    public virtual UserDetails Details {       
       get {
            if (details == null)
                details = new UserDetails();

            return details;
        }
        set { details = value;}
    }

}

public class UserDetails {
     private Guid id;

    private User user;

    public virtual Guid Id{
        get { return id; }
        set { id = value; }
    }
}

When I create a new user and the details, it inserts the details first with a new generated guid, but in the table the guid is empty ('')

This is the debug from log4net

2009-03-17 09:48:34,640 [8] DEBUG NHibernate.Type.GuidType - binding '499eff7e-390c-411a-955d-29cdba6f557e' to parameter: 0
2009-03-17 09:48:34,640 [8] DEBUG NHibernate.SQL - INSERT INTO TLPOSAddresses (UniqueTLPOSAddress) VALUES (?); p0 = '499eff7e-390c-411a-955d-29cdba6f557e'


So that looks fine, but still an empty value is inserted into the database????

The database is Sql Anywhere 9.

I appreciate your help!

Linda


Top
 Profile  
 
 Post subject: Solution
PostPosted: Tue Mar 17, 2009 1:21 am 
Newbie

Joined: Mon Mar 16, 2009 9:24 pm
Posts: 2
Location: Australia
Hi,

I solved this problem by changing the driver from Odbc to ASAClientDriver. No idea why Odbc was giving the problem, just happy to have a solution!

Thanks!


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

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.