-->
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: NHibernate mapping and LOAD problem
PostPosted: Wed Sep 20, 2006 4:50 am 
Newbie

Joined: Wed Sep 13, 2006 6:41 am
Posts: 3
Hi everyone,

I have a problem with object mapping.

I have to manage a very large table with more then 200 columns.
I use column attribute to assign mapping between objects attributes and table columns.
For exmaple if I use column names like these:

column="CPO2_A112_XXXX_YYY"
column="CP02_A136_XXXX_YYY"

where XXXX_YYY represents the real name and type of the columns, NHibernate raises a class cast exception in Load operations.

The exception is raised only when I try to load an objet from the DataBase (I use an Oracle DB) and I have no problems with store operations.

I checked the mapping file more times and it seams to be correct.

If I use column names like these:

column="CPO2_XXXX_A1S_YYY"
column="CP02_XXXX_A1L_YYY"

no exceptions are raised but loaded object is different from the original in some attributes.

Using NHibernate.Cfg.Environment.ShowSql property, I saw the query produced by save operations includes all columns defined into the xml mapping file, but the query produced by Load method does not (I use isession.Load(typeof(ObjectClass), ObjectID) method, the primary key is a long). Not included columns are inizialized to 0 or empty strings in object instantiation and then result different from original data.

I seen that NHibernate translate column names using aliases like:
CPO2_A1ZZ_0_ where ZZ is a progressive number.

I would like to now if there are some limitation in column property syntax or length and/or the column naming convengion I use could create translation problems.

Thanks for Your help,
Gionni


Top
 Profile  
 
 Post subject: Re: NHibernate mapping and LOAD problem
PostPosted: Wed Sep 20, 2006 5:27 am 
Expert
Expert

Joined: Thu Jan 19, 2006 4:29 pm
Posts: 348
Gionni wrote:
I have to manage a very large table with more then 200 columns.
I use column attribute to assign mapping between objects attributes and table columns.
For exmaple if I use column names like these:

column="CPO2_A112_XXXX_YYY"
column="CP02_A136_XXXX_YYY"

where XXXX_YYY represents the real name and type of the columns, NHibernate raises a class cast exception in Load operations.


If NHibernate is creating incorrect aliases in query (see downward), then it might explain the cast exception - properties and aliases might got swapped, so the value of string column is tried to load into int column, for example.

Gionni wrote:
If I use column names like these:

column="CPO2_XXXX_A1S_YYY"
column="CP02_XXXX_A1L_YYY"

no exceptions are raised but loaded object is different from the original in some attributes.

Using NHibernate.Cfg.Environment.ShowSql property, I saw the query produced by save operations includes all columns defined into the xml mapping file, but the query produced by Load method does not (I use isession.Load(typeof(ObjectClass), ObjectID) method, the primary key is a long). Not included columns are inizialized to 0 or empty strings in object instantiation and then result different from original data.

I seen that NHibernate translate column names using aliases like:
CPO2_A1ZZ_0_ where ZZ is a progressive number.


Sounds like NHibernate is creating same alias for multiple columns, and omitting column from query if aliases are same... You might want to create and jira issue for that.

Gionni wrote:
I would like to now if there are some limitation in column property syntax or length and/or the column naming convengion I use could create translation problems.


I would hope there are no syntax/format limitations. But there might be some bugs ;)

Gert

_________________
If a reply helps You, rate it!


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.