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.  [ 10 posts ] 
Author Message
 Post subject: Error with Computed Property inside <component> block
PostPosted: Fri Sep 29, 2006 11:32 am 
Newbie

Joined: Wed Jun 07, 2006 3:15 am
Posts: 14
Hi,

I don't seem to be able to declare a computed property (formula) inside a component (v1.2.0 beta)

Code:
...
<component name="NodeInfo" class="NHibernateHelper.NestedSet.NodeInfo, NHibernateHelper" update="false">
  <parent name="Node"/>
  <property name="Left" type="Int64">
    <column name="ns_left" sql-type="bigint" not-null="true" />
  </property>
  <property name="Right" type="Int64">
    <column name="ns_right" sql-type="bigint" not-null="true" />
  </property>
  <property name="Depth" type="Int32" formula="(SELECT Count(*) FROM document_categories dc WHERE dc.ns_left &lt;= ns_left AND dc.ns_right > ns_left)" />
</component>
...


Exception

{"Could not compile the mapping document: MiddleLayer.Mappings.DocumentCategory.hbm.xml"}

Inner Exception

{"Unable to cast object of type 'NHibernate.Mapping.Formula' to type 'NHibernate.Mapping.Column'."}

The <property name="Depth" ... /> works fine when placed outside the <component> along with a property "public int Depth" in the main class, but if I try to move this property (both in mapping and class file) inside NodeInfo I get the above exception.

Both Left and Right properties used to be in the main class as well and I succesfully transfered them inside NodeInfo component, but I can't do the same for the computed property.

Any ideas? Tia.
Nikos.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 02, 2006 6:14 am 
Newbie

Joined: Wed Jun 07, 2006 3:15 am
Posts: 14
Could this be a bug in NHibernate? It says "Could not compile the mapping document" even though the mapping file validates against the .xsd schema


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 02, 2006 6:17 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Yes, looks like a bug, please report it.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 02, 2006 9:18 am 
Newbie

Joined: Wed Jun 07, 2006 3:15 am
Posts: 14
sergey wrote:
Yes, looks like a bug, please report it.

Thx for the response. But I am not sure where I should report the bug :).


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 02, 2006 11:07 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
http://jira.nhibernate.org


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 02, 2007 5:20 am 
Newbie

Joined: Mon Feb 26, 2007 12:53 pm
Posts: 8
I have the same problem with 1.2.0.CR1 :(

Here it's was fixed in 1.2.0.Beta 2 !!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 02, 2007 6:04 am 
Newbie

Joined: Mon Feb 26, 2007 12:53 pm
Posts: 8
http://jira.nhibernate.org/browse/NH-961


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 02, 2007 10:44 am 
Newbie

Joined: Mon Feb 26, 2007 12:53 pm
Posts: 8
Sorry, it's in <composite-element> and not in <component> (I think it's the same bug).
The test case:

sql:
CREATE TABLE TEST_TABLE1
(
ID1 NUMBER,
PROP1 VARCHAR2(10 BYTE)
);

CREATE TABLE TEST_TABLE2
(
ID2 NUMBER,
ID1 NUMBER NOT NULL,
PRO2 NVARCHAR2(10)
);

ALTER TABLE TEST_TABLE1 ADD (
CONSTRAINT PK_TEST_TABLE1 PRIMARY KEY (ID1));

ALTER TABLE TEST_TABLE2 ADD (
CONSTRAINT PK_TEST_TABELE2 PRIMARY KEY (ID2));

ALTER TABLE TEST_TABLE2 ADD (
CONSTRAINT FK1_TEST_TABLE2 FOREIGN KEY (ID1)
REFERENCES TEST_TABLE1 (ID1));

c#:
public class Class1
{
private int _id;

public virtual int Id
{
get { return _id; }
set { _id = value; }
}

private String _prop1;

public virtual String Prop1
{
get { return _prop1; }
set { _prop1 = value; }
}

private IList<Class2> _elements;

public virtual IList<Class2> Elements
{
get { return _elements; }
set { _elements = value; }
}
}

public class Class2
{
private int _id;

public virtual int Id
{
get { return _id; }
set { _id = value; }
}

private String _prop2;

public virtual String Prop2
{
get { return _prop2; }
set { _prop2 = value; }
}


mapping:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="Class1" table="TEST_TABLE1" mutable="true" lazy="false">
<id name="Id" column="ID1" type="Int32">
<generator class="assigned" />
</id>
<property name="Prop1" column="PROP1" not-null="true"/>

<bag name="Elements" lazy="false" cascade="all" table="TEST_TABLE2">
<key column="ID1"/>
<composite-element class="Class2">
<property name="Id" column="ID2" not-null="true"/>
<property name="Prop2" formula="( 'DUMMY -' || PRO2 )" not-null="true"/>
</composite-element>
</bag>
</class>
</hibernate-mapping>

When a computed property is placed inside a <composite-element> block an exception is raised..
{"Unable to cast object of type 'NHibernate.Mapping.Formula' to type 'NHibernate.Mapping.Column'";}


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 05, 2007 2:23 am 
Newbie

Joined: Mon Feb 26, 2007 12:53 pm
Posts: 8
I'm blocked qith bug :(

please help


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 05, 2007 5:12 am 
Newbie

Joined: Mon Feb 26, 2007 12:53 pm
Posts: 8
I rewrite correctly the bug report here : http://jira.nhibernate.org/browse/NH-965 ( Fix Version/s: 1.2.0.GA )


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 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.