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.  [ 9 posts ] 
Author Message
 Post subject: NHibernateContrib: mapping attributes created in wrong order
PostPosted: Wed Jun 14, 2006 11:07 am 
Beginner
Beginner

Joined: Wed Oct 05, 2005 2:08 pm
Posts: 23
I get the following error when attempting to parse this schema (produced using Mapping.Attributes):Cannot extend unmapped class: nhibernate2test.BLL.Tank

Here is the stack trace:

at NHibernate.Cfg.HbmBinder.GetSuperclass(Mappings model, XmlNode subnode) in c:\net\nhibernate\nhibernate\src\NHibernate\Cfg\HbmBinder.cs:line 1689
at NHibernate.Cfg.HbmBinder.BindRoot(XmlDocument doc, Mappings model) in c:\net\nhibernate\nhibernate\src\NHibernate\Cfg\HbmBinder.cs:line 1600
at NHibernate.Cfg.Configuration.AddValidatedDocument(XmlDocument doc) in c:\net\nhibernate\nhibernate\src\NHibernate\Cfg\Configuration.cs:line 375
at NHibernate.Cfg.Configuration.AddXmlReader(XmlTextReader hbmReader) in c:\net\nhibernate\nhibernate\src\NHibernate\Cfg\Configuration.cs:line 1556
at NHibernate.Cfg.Configuration.AddInputStream(Stream xmlInputStream) in c:\net\nhibernate\nhibernate\src\NHibernate\Cfg\Configuration.cs:line 421
at nhibernate2test.Form1.Form1_Load(Object sender, EventArgs e) in C:\sourcecode\nhibernate2test\nhibernate2test\Form1.vb:line 21
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at nhibernate2test.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()"

Please notice that Tank is mapped in bold.


Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
  <class name="nhibernate2test.BLL.Equipment, nhibernate2test.BLL" lazy="false" table="bv_equipment_with_discriminator">
    <id column="equipment_id" type="Guid">
      <generator class="guid" />
    </id>
    <discriminator column="discriminator" type="String" />
    <property name="Name" type="String" column="equipment_name" />
    <property name="Description" type="String" column="equipment_description" />
    <property name="BaanSupplierID" type="String" column="baan_supplier_id" />
    <property name="BaanItemID" type="String" column="baan_item_id" />
    <property name="BaanPackageCode" column="baan_package_code" />
    <property name="BaanNumber" type="String" column="baan_number" />
    <property name="BaanItemGroup" column="baan_item_group" />
    <property name="ManufacturerID" column="manufacturer_id" />
    <property name="VendorID" column="vendor_id" />
    <property name="Actual" column="actual" />
    <property name="ShippingWeight" column="shipping_weight" />
    <property name="ShippingWeightUnits" column="shiipping_weight_units_id" />
    <property name="RectangularShape" column="rectangular_shape" />
    <property name="Diameter" column="diameter" />
    <property name="Length" column="length" />
    <property name="Width" column="width" />
    <property name="Height" column="height" />
    <property name="CustomItem" column="custom_item" />
    <property name="ProjectNumber" type="String" column="project_number" />
    <property name="CreatedBy" column="created_by" />
    <property name="CreatedDate" column="created_Date" />
    <property name="ModifiedBy" column="modified_by" />
    <property name="ModifiedDate" column="modified_Date" />
    <property name="RegionSbuID" column="region_sbu_id" />
    <property name="Cost" column="cost" />
    <property name="CurrencyID" type="String" column="currency_id" />
    <property name="ValidDate" column="valid_date" />
    <property name="ExpiryDate" column="expiry_date" />
    <property name="QuoteReference" type="String" column="quote_reference" />
  </class>
  <subclass name="nhibernate2test.BLL.AerobicTank, nhibernate2test.BLL" lazy="false" extends="nhibernate2test.BLL.Tank, nhibernate2test.BLL" discriminator-value="Aerobic" />
  <subclass name="nhibernate2test.BLL.AirDiffuser, nhibernate2test.BLL" lazy="false" extends="nhibernate2test.BLL.Equipment, nhibernate2test.BLL" discriminator-value="Air Diffusers">
    <property name="ActualFlow" column="flow_actual" />
    <property name="FlowUpperLimit" column="flow_upper_limit" />
    <property name="FlowLowerLimit" column="flow_lower_limit" />
    <property name="FlowUnits" column="flow_units_id" />
    <property name="DesignDepth" column="air_diffuser_design_depth" />
    <property name="Footprint" column="air_diffuser_footprint" />
    <property name="SOTR" column="air_diffuser_sotr" />
    <property name="Flow" column="air_diffuser_flow" />
  </subclass>
  <subclass name="nhibernate2test.BLL.AirDrier, nhibernate2test.BLL" lazy="false" extends="nhibernate2test.BLL.Equipment, nhibernate2test.BLL" discriminator-value="Air Driers">
    <property name="Material" column="air_drier_material_id" />
    <property name="ActualFlow" column="flow_actual" />
    <property name="FlowUpperLimit" column="flow_upper_limit" />
    <property name="FlowLowerLimit" column="flow_lower_limit" />
    <property name="FlowUnits" column="flow_units_id" />
    <property name="MinimumOutputDewPoint" column="air_drier_min_output_dewpoint" />
    <property name="UpperOperatingTemperature" column="air_drier_upper_operating_temp" />
    <property name="LowerOperatingTemperature" column="air_drier_lower_operating_temp" />
    <property name="Stage" column="air_drier_stages_id" />
  </subclass>
  <subclass name="nhibernate2test.BLL.AnoxicTank, nhibernate2test.BLL" lazy="false" extends="nhibernate2test.BLL.Tank, nhibernate2test.BLL" discriminator-value="Anoxic" />
  <subclass name="nhibernate2test.BLL.Blower, nhibernate2test.BLL" lazy="false" extends="nhibernate2test.BLL.Equipment, nhibernate2test.BLL" discriminator-value="Blowers">
    <property name="ConstructionMaterial" column="blower_construction_id" />
    <property name="SPL" column="blower_spl" />
    <property name="SoundEnclosureIncluded" column="blower_sound_enclosure_included" />
    <property name="SoundEnclosureConstructionMaterial" column="blower_sound_enclosure_material_id" />
  </subclass>
  <subclass name="nhibernate2test.BLL.BreakTank, nhibernate2test.BLL" lazy="false" extends="nhibernate2test.BLL.Tank, nhibernate2test.BLL" discriminator-value="Break" />
  <subclass name="nhibernate2test.BLL.ChemicalBackpulseTank, nhibernate2test.BLL" lazy="false" extends="nhibernate2test.BLL.Tank, nhibernate2test.BLL" discriminator-value="Chemical/Backpulse" />
  <subclass name="nhibernate2test.BLL.CIPTank, nhibernate2test.BLL" lazy="false" extends="nhibernate2test.BLL.Tank, nhibernate2test.BLL" discriminator-value="CIP" />
  <subclass name="nhibernate2test.BLL.CoarseAirDiffuser, nhibernate2test.BLL" lazy="false" extends="nhibernate2test.BLL.AirDiffuser, nhibernate2test.BLL" discriminator-value="Coarse Air Diffuser">
    <property name="ConstructionMaterial" column="coarse_air_diffuser_construction_id" />
  </subclass>
  <subclass name="nhibernate2test.BLL.Compressor, nhibernate2test.BLL" lazy="false" extends="nhibernate2test.BLL.Equipment, nhibernate2test.BLL" discriminator-value="Compressors">
    <property name="ConstructionMaterial" column="compressor_construction_id" />
    <property name="SPL" column="compressor_spl" />
    <property name="SoundEnclosureIncluded" column="compressor_sound_enclosure_included" />
    <property name="OilLubricated" column="compressor_oil_lubricated" />
    <property name="Mounting" column="compressor_mounting_id" />
  </subclass>
  <subclass name="nhibernate2test.BLL.DesiccantAdsorptionAirDrier, nhibernate2test.BLL" lazy="false" extends="nhibernate2test.BLL.AirDrier, nhibernate2test.BLL" discriminator-value="Desiccant adsorption" />
  <subclass name="nhibernate2test.BLL.DipTank, nhibernate2test.BLL" lazy="false" extends="nhibernate2test.BLL.Tank, nhibernate2test.BLL" discriminator-value="Dip" />
  <subclass name="nhibernate2test.BLL.FineBubbleAirDiffuser, nhibernate2test.BLL" lazy="false" extends="nhibernate2test.BLL.AirDiffuser, nhibernate2test.BLL" discriminator-value="Fine Bubble Diffuser">
    <property name="DiscDiameter" column="fine_bubble_disc_diameter" />
    <property name="DiscMaterial" column="fine_bubble_disc_material_id" />
    <property name="BasePlateMaterial" column="fine_bubble_baseplate_material_id" />
  </subclass>
  <subclass name="nhibernate2test.BLL.MembraneTank, nhibernate2test.BLL" lazy="false" extends="nhibernate2test.BLL.Tank, nhibernate2test.BLL" discriminator-value="Membrane">
    <property name="BeamFrameIncluded" column="membrane_tank_beam_frame_included" />
    <property name="BeamConstructionMaterial" column="membrane_tank_beam_construction_id" />
    <property name="FloorStandingFrameIncluded" column="membrane_tank_floor_standing_frame_included" />
    <property name="FloorStandingConstructionMaterial" column="membrane_tank_floor_standing_construction_id" />
    <property name="WalkwayCoveringIncluded" column="membrane_tank_walkway_covering_included" />
    <property name="WalkwayCoveringConstructionMaterial" column="membrane_tank_walkway_covering_construction_id" />
    <property name="HandrailIncluded" column="membrane_tank_handrail_included" />
    <property name="HandrailConstructionMaterial" column="membrane_tank_handrail_construction_id" />
  </subclass>
  <subclass name="nhibernate2test.BLL.MultistageCentrifugalBlower, nhibernate2test.BLL" lazy="false" extends="nhibernate2test.BLL.Blower, nhibernate2test.BLL" discriminator-value="Multistage Centrifugal" />
  <subclass name="nhibernate2test.BLL.OtherTank, nhibernate2test.BLL" lazy="false" extends="nhibernate2test.BLL.Tank, nhibernate2test.BLL" discriminator-value="Other" />
  <subclass name="nhibernate2test.BLL.PistonCompressor, nhibernate2test.BLL" lazy="false" extends="nhibernate2test.BLL.Compressor, nhibernate2test.BLL" discriminator-value="Piston" />
  <subclass name="nhibernate2test.BLL.PositiveDisplacementBlower, nhibernate2test.BLL" lazy="false" extends="nhibernate2test.BLL.Blower, nhibernate2test.BLL" discriminator-value="Positive Displacement" />
  <subclass name="nhibernate2test.BLL.RefrigerationAirDrier, nhibernate2test.BLL" lazy="false" extends="nhibernate2test.BLL.AirDrier, nhibernate2test.BLL" discriminator-value="Refrigeration" />
  <subclass name="nhibernate2test.BLL.RegenerativeBlower, nhibernate2test.BLL" lazy="false" extends="nhibernate2test.BLL.Blower, nhibernate2test.BLL" discriminator-value="Regenerative" />
  <subclass name="nhibernate2test.BLL.RotaryScrewCompressor, nhibernate2test.BLL" lazy="false" extends="nhibernate2test.BLL.Compressor, nhibernate2test.BLL" discriminator-value="Rotary Screw" />
  <subclass name="nhibernate2test.BLL.SingleStageCentrifugalBlower, nhibernate2test.BLL" lazy="false" extends="nhibernate2test.BLL.Blower, nhibernate2test.BLL" discriminator-value="Single Stage Centrifugal" />

<subclass name="nhibernate2test.BLL.Tank, nhibernate2test.BLL" lazy="false" extends="nhibernate2test.BLL.Equipment, nhibernate2test.BLL" discriminator-value="Tanks">
<property name="ConstructionMaterial" column="tank_construction_id" />
<property name="SlopeID" column="tank_slope_id" />
<property name="TopClosed" column="tank_top_closed" />
<property name="SoundEnclosureConstructionMaterial" column="blower_sound_enclosure_material_id" />
<property name="ExteriorPaint" column="tank_exterior_paint_id" />
<property name="InternalCoating" column="tank_internal_coating_id" />
</subclass>

Code:
<subclass name="nhibernate2test.BLL.Valve, nhibernate2test.BLL" lazy="false" extends="nhibernate2test.BLL.Equipment, nhibernate2test.BLL" discriminator-value="Valves">
    <property name="BodyConstructionMaterial" column="valve_body_construction_id" />
    <property name="SeatConstructionMaterial" column="valve_seat_construction_id" />
    <property name="SealConstructionMaterial" column="valve_seal_construction_id" />
  </subclass>
  <subclass name="nhibernate2test.BLL.ButterflyValve, nhibernate2test.BLL" lazy="false" extends="nhibernate2test.BLL.Valve, nhibernate2test.BLL" discriminator-value="Butterfly" />
  <subclass name="nhibernate2test.BLL.BallValve, nhibernate2test.BLL" lazy="false" extends="nhibernate2test.BLL.Valve, nhibernate2test.BLL" discriminator-value="Ball" />
  <subclass name="nhibernate2test.BLL.CheckValve, nhibernate2test.BLL" lazy="false" extends="nhibernate2test.BLL.Valve, nhibernate2test.BLL" discriminator-value="Check" />
  <subclass name="nhibernate2test.BLL.KnifeGateValve, nhibernate2test.BLL" lazy="false" extends="nhibernate2test.BLL.Valve, nhibernate2test.BLL" discriminator-value="Knife Gate" />
  <subclass name="nhibernate2test.BLL.DiaphragmValve, nhibernate2test.BLL" lazy="false" extends="nhibernate2test.BLL.Valve, nhibernate2test.BLL" discriminator-value="Diaphragm" />
  <subclass name="nhibernate2test.BLL.GlobeValve, nhibernate2test.BLL" lazy="false" extends="nhibernate2test.BLL.Valve, nhibernate2test.BLL" discriminator-value="Globe" />
  <subclass name="nhibernate2test.BLL.NeedleValve, nhibernate2test.BLL" lazy="false" extends="nhibernate2test.BLL.Valve, nhibernate2test.BLL" discriminator-value="Needle" />
  <subclass name="nhibernate2test.BLL.SluiceGateValve, nhibernate2test.BLL" lazy="false" extends="nhibernate2test.BLL.Valve, nhibernate2test.BLL" discriminator-value="Sluice Gate" />
  <subclass name="nhibernate2test.BLL.MudValve, nhibernate2test.BLL" lazy="false" extends="nhibernate2test.BLL.Valve, nhibernate2test.BLL" discriminator-value="Mud Valve" />
  <subclass name="nhibernate2test.BLL.BallCheckValve, nhibernate2test.BLL" lazy="false" extends="nhibernate2test.BLL.Valve, nhibernate2test.BLL" discriminator-value="Ball Check" />
  <subclass name="nhibernate2test.BLL.AngleSeatValve, nhibernate2test.BLL" lazy="false" extends="nhibernate2test.BLL.Valve, nhibernate2test.BLL" discriminator-value="Angle Seat" />
  <subclass name="nhibernate2test.BLL.OtherValve, nhibernate2test.BLL" lazy="false" extends="nhibernate2test.BLL.Valve, nhibernate2test.BLL" discriminator-value="Other" />
</hibernate-mapping>


Last edited by jhusain on Fri Jun 16, 2006 10:25 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 14, 2006 3:16 pm 
Beginner
Beginner

Joined: Wed Oct 05, 2005 5:35 am
Posts: 47
Location: France
Probably a dumb suggestion, but did you try moving nhibernate2test.BLL.Tank declaration above nhibernate2test.BLL.AerobicTank?


Top
 Profile  
 
 Post subject: Not a dumb suggestion at all.
PostPosted: Fri Jun 16, 2006 10:23 am 
Beginner
Beginner

Joined: Wed Oct 05, 2005 2:08 pm
Posts: 23
I tried that and it worked. The problem is that I'm using the mapping attributes in NHibernateContrib and that's the way it serializes the schema at runtime. Does anyone know any way to ensure that the serializer serializes the subclasses in the right order? I've tried using the order field in the subclass attribute and that doesn't seem to affect the order. However I would have thought that the serializer would be able to infer the correct order without requiring any extra information by following the subclass definitions up the chain.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 16, 2006 2:02 pm 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
Feel free to create a JIRA issue: http://jira.nhibernate.org/
I will try to add this improvement.

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
 Post subject: Link doesn't work
PostPosted: Fri Aug 04, 2006 3:55 pm 
Beginner
Beginner

Joined: Wed Oct 05, 2005 2:08 pm
Posts: 23
I'd love to but that link doesn't work. Do you have an alternate solution?

Thanks very much for this very useful software. Despite the bug it has made my life much easier.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 04, 2006 4:39 pm 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
I don't know why you can't access this website... It is working for me. You may try again.

Anyway, your issue is already solved :)
Cf. http://jira.nhibernate.org/browse/NH-652
Can you check out the SVN version of NHibernate and try it to see if it really works?

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
 Post subject: Works!
PostPosted: Tue Aug 15, 2006 11:15 am 
Beginner
Beginner

Joined: Wed Oct 05, 2005 2:08 pm
Posts: 23
Thanks very much!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 27, 2006 3:29 pm 
Newbie

Joined: Wed Dec 20, 2006 9:00 am
Posts: 10
Location: Brazil (GMT-3)
KPixel wrote:
I don't know why you can't access this website... It is working for me. You may try again.

Anyway, your issue is already solved :)
Cf. http://jira.nhibernate.org/browse/NH-652
Can you check out the SVN version of NHibernate and try it to see if it really works?


Hi! I know this topic is old, but I thought about letting some info for people whom, like me, stumbles into such problem.
Well, I'm still using NHibernate 1.0.2.0 and I can see from NH-652 that it was solved for 1.2.0Beta1, not an option at the moment. Nevertheless, I found a easy workaround for 1.0.2: the order of loading can be controlled by the name of the source file containing the class. I prefixed my source file name with an "01" making it the "first" in the assembly and that corrected the problem, I'm using Visual Studio 2005.

_________________
If a post helps you, rate it!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 28, 2006 9:31 pm 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
Note that NHibernate.Mapping.Attributes can be easily back-ported to NH1.0.2. All you have to do is:
- Copy nhibernate-mapping-2.0.xsd from \nhibernate\src\NHibernate\ to \nhibernate\src\NHibernate.Mapping.Attributes\
- Open the solution: NHibernate.Mapping.Attributes.Generator-2.0.sln
- In NHibernate.Mapping.Attributes project, remove the file nhibernate-mapping.xsd and add nhibernate-mapping-2.0.xsd (+ make it "EmbeddedRessource")
- Search for "nhibernate-mapping.xsd" in all files and replace it by "nhibernate-mapping-2.0.xsd"
- Run the Generator project
- Compile NHibernate.Mapping.Attributes and use it.
Voilà ! :)

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


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