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: field [snip] should not be public nor internal
PostPosted: Sat Aug 09, 2008 5:50 pm 
Newbie

Joined: Sat Aug 09, 2008 5:33 pm
Posts: 1
I got the error: "field [snip] should not be public nor internal"

AFAICT, it looks like only class properties are mappable, not fields. Please select from one of the possible explanations below:

a) We haven't gotten around to it. Send us a patch if you do
b) Shame on you for having public fields
c) a & b
d) none of the above

NHibernate version:
2.0.0 CR1

Mapping documents:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="GCheckout.AutoGen.NewOrderNotification, GCheckout" table="orders">
<id name="googleordernumber" column="googleordernumber" type="String" length="256">
<generator class="assigned" />
</id>
</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():

Code:
            ISession session = factory.OpenSession();
            ITransaction transaction = session.BeginTransaction();

            // Tell NHibernate that this object should be saved
            session.Save(newOrder);

            // commit all of the changes to the DB and close the ISession
            transaction.Commit();
            session.Close();


Full stack trace of any exception that occurs:

A first chance exception of type 'NHibernate.InvalidProxyTypeException' occurred in NHibernate.DLL
A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
A first chance exception of type 'NUnit.Core.NUnitException' occurred in nunit.core.dll
############################################################################
############## F A I L U R E S #################
1) VendantUtil.tests.NotificationProcessorTest.BasicTest :
NHibernate.InvalidProxyTypeException : The following types may not be used as proxies:
GCheckout.AutoGen.NewOrderNotification: field buyermarketingpreferences should not be public nor internal
GCheckout.AutoGen.NewOrderNotification: field buyerbillingaddress should not be public nor internal
GCheckout.AutoGen.NewOrderNotification: field timestamp should not be public nor internal
GCheckout.AutoGen.NewOrderNotification: field googleordernumber should not be public nor internal
GCheckout.AutoGen.NewOrderNotification: field buyerid should not be public nor internal
GCheckout.AutoGen.NewOrderNotification: field buyershippingaddress should not be public nor internal
GCheckout.AutoGen.NewOrderNotification: field shoppingcart should not be public nor internal
GCheckout.AutoGen.NewOrderNotification: field ordertotal should not be public nor internal
GCheckout.AutoGen.NewOrderNotification: field fulfillmentorderstate should not be public nor internal
GCheckout.AutoGen.NewOrderNotification: field serialnumber should not be public nor internal
GCheckout.AutoGen.NewOrderNotification: field orderadjustment should not be public nor internal
GCheckout.AutoGen.NewOrderNotification: field promotions should not be public nor internal
GCheckout.AutoGen.NewOrderNotification: field financialorderstate should not be public nor internal
at
c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Cfg\Configuration.cs(802)
at
c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Cfg\Configuration.cs(981)
at


Name and version of the database you are using:
MySQL 5.0.16

The generated SQL (show_sql=true):
N/A


Top
 Profile  
 
 Post subject: Re: field [snip] should not be public nor internal
PostPosted: Sat Aug 09, 2008 6:24 pm 
Regular
Regular

Joined: Mon Aug 29, 2005 3:07 pm
Posts: 77
vharron wrote:
I got the error: "field [snip] should not be public nor internal"

AFAICT, it looks like only class properties are mappable, not fields. Please select from one of the possible explanations below:

a) We haven't gotten around to it. Send us a patch if you do
b) Shame on you for having public fields
c) a & b
d) none of the above

Option e: shame on you;
the NHibernate document will tell you something about field access in your mapping file.
For instance:
Code:
<property name="MyProperty" column="..." access="field"/>

:)

But, why would you want to use public fields ? at least, is that what you're doing ?
Why don't you write your class like this:
Code:
public class MyClass
{
     public int Id
     {
            get;
            private set;
     }
}
Then, you can just map your Id or any other 'Property' as a property.


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.