Hello,
How does one go about reporting a new bug in NH jira?
I encountered the following issue.

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
                                     assembly="MyDomain"
                                     namespace="MyDomain.Model">

    <class name="UserProfile">

    <composite-id >
      <key-many-to-one name="Id" column="UserId" class="User" />
    </composite-id>

  </class>
</hibernate-mapping>

session.Get<UserProfile>(user);

During debug-mode, that will throw an InvalidCastException from
ComponentType.ToLoggableString() method. It's fine during non debug-mode.

The cause of that error, as I tracked down, is due to an attempt to get a
string description from entity's ID (User object) by calling
ComponentType.ToLoggableString().
Since we specify neither the property-name nor the class attribute in the
<composite-id> element, nhibernate mistakenly uses EmbeddedComponentType of
UserProfile class (instead of User class) in its attempt to GuessEntityMode
of our User object. This will obviously fail, and the logger decides to
throw exception on this situation (it should at least resort to other
method.. afterall its sole purpose is just to print the string
representation of the Id object).

There's no appropriate workaround that I can think of that wouldn't
compromise what I want to achieve. I can't specify class name in the
<composite-id> element because NH will (inappropriately) complaint that this
entity doesnt have an ID (because I set the class without the
property-name). And obviously I can't specify the property-name because I
want to have "many-to-one"ed complex type as my ID.

I strongly believe this is a bug that needs to be fixed, and make the
logging less intrusive. This issue has been raiseed in java's Hibernate
before (http://opensource.atlassian.com/projects/hibernate/browse/HHH-3148)

Some ways to fix this that I can think of: not relying on tuplizer for
logging at all, or may be resort to other way to produce the logging string
in situations when no tuplizer is found (rather than throwing an exception).

Cheers

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to nhus...@googlegroups.com.
To unsubscribe from this group, send email to 
nhusers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to