-->
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.  [ 1 post ] 
Author Message
 Post subject: string[] not saving using <array ... /> mapping
PostPosted: Tue Mar 27, 2007 7:13 am 
Newbie

Joined: Wed Aug 16, 2006 12:56 pm
Posts: 4
I am unable to get a string[] to save to a relational table using NHibernate

My schema is:

Code:
[color=blue]<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
   <class name="Phibro.EnergyTrading.ClientLibrary.Entity.ReferenceData.ReferenceItems.PortfolioCrossExchangeProduct, Phibro.EnergyTrading.ClientLibrary"
         lazy="false"   table="rd_portfolio_cross_exchange_product">
      <id name="Id" column="id" type="Int32" access="nosetter.camelcase-underscore">
         <generator class="identity"/>
      </id>

      <property name="Name" column="name" type="String"
         length="50" insert="true" update="false" not-null="true" access="nosetter.camelcase-underscore" />

      <many-to-one name="DifferenceUnit" column="difference_unit_id" not-null="true" cascade="none"
         access="nosetter.camelcase-underscore"
         class="Phibro.EnergyTrading.ClientLibrary.Entity.ReferenceData.ReferenceItems.PricingUnit, Phibro.EnergyTrading.ClientLibrary" />

      <many-to-one name="ResultUnit" column="result_unit_id" not-null="true" cascade="none"
         access="nosetter.camelcase-underscore"
         class="Phibro.EnergyTrading.ClientLibrary.Entity.ReferenceData.ReferenceItems.PricingUnit, Phibro.EnergyTrading.ClientLibrary" />

      <many-to-one name="NearTermBasisProduct" column="near_basis_port_exch_prod_id"
         not-null="true" cascade="none" access="nosetter.camelcase-underscore"
         class="Phibro.EnergyTrading.ClientLibrary.Entity.ReferenceData.ReferenceItems.PortfolioExchangeProduct, Phibro.EnergyTrading.ClientLibrary"/>

      <many-to-one name="FarTermBasisProduct" column="far_basis_port_exch_prod_id"
         not-null="true" cascade="none" access="nosetter.camelcase-underscore"
         class="Phibro.EnergyTrading.ClientLibrary.Entity.ReferenceData.ReferenceItems.PortfolioExchangeProduct, Phibro.EnergyTrading.ClientLibrary"/>

      <property name="NearTermCurveTypePersistedValue" column="near_basis_type_id" type="String"
         length="10" insert="true" update="false" not-null="true" />

      <property name="FarTermCurveTypePersistedValue" column="far_basis_type_id" type="String"
         length="10" insert="true" update="false" not-null="true" />

      <property name="NearTermEndMonth" type="DateTime"
        insert="true" update="true" not-null="false"
        column="near_end_month" />

      <property name="FarTermEndMonth" type="DateTime"
        insert="true" update="true" not-null="false"
        column="far_end_month" />

      <property name="AllowPriceCurveSnapshot" type="Boolean"
        insert="true" update="true" not-null="true"
        column="allow_snapshot"/>

      <array name="AlternateNames" access="nosetter.camelcase-underscore" cascade="all-delete-orphan"
       table="rd_port_cross_exch_prod_alt_name">
         <key column="portfolio_cross_exchange_product_id"/>
         <index column="alt_name_index" type="Int32"/>
         <element column="alternative_name" type="String" length="50"/>
      </array>
   </class>
</hibernate-mapping>[/color]


The master table is defined as:

Code:
CREATE TABLE [rd_portfolio_cross_exchange_product] (
   [id] [int] IDENTITY (1, 1) NOT NULL ,
   [name] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
   [difference_unit_id] [int] NOT NULL ,
   [result_unit_id] [int] NOT NULL ,
   [near_basis_port_exch_prod_id] [int] NOT NULL ,
   [far_basis_port_exch_prod_id] [int] NOT NULL ,
   [near_basis_type_id] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
   [far_basis_type_id] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
   [near_end_month] [datetime] NOT NULL ,
   [far_end_month] [datetime] NOT NULL ,
   [allow_snapshot] [bit] NOT NULL ,
   CONSTRAINT [PK_rd_portfolio_cross_exchange_product] PRIMARY KEY  CLUSTERED
   (
      [id]
   )  ON [PRIMARY] ,
   CONSTRAINT [FK_rd_portfolio_cross_exchange_product_rd_portfolio_exchange_product] FOREIGN KEY
   (
      [near_basis_port_exch_prod_id]
   ) REFERENCES [rd_portfolio_exchange_product] (
      [id]
   ),
   CONSTRAINT [FK_rd_portfolio_cross_exchange_product_rd_portfolio_exchange_product1] FOREIGN KEY
   (
      [far_basis_port_exch_prod_id]
   ) REFERENCES [rd_portfolio_exchange_product] (
      [id]
   ),
   CONSTRAINT [FK_rd_portfolio_cross_exchange_product_rd_term_basis_curve_type] FOREIGN KEY
   (
      [near_basis_type_id]
   ) REFERENCES [rd_term_basis_curve_type] (
      [id]
   ),
   CONSTRAINT [FK_rd_portfolio_cross_exchange_product_rd_term_basis_curve_type1] FOREIGN KEY
   (
      [far_basis_type_id]
   ) REFERENCES [rd_term_basis_curve_type] (
      [id]
   ),
   CONSTRAINT [FK_rd_portfolio_cross_exchange_product_rd_unit] FOREIGN KEY
   (
      [difference_unit_id]
   ) REFERENCES [rd_unit] (
      [id]
   ),
   CONSTRAINT [FK_rd_portfolio_cross_exchange_product_rd_unit1] FOREIGN KEY
   (
      [result_unit_id]
   ) REFERENCES [rd_unit] (
      [id]
   )
) ON [PRIMARY]
GO


The child table is defined as:

Code:
CREATE TABLE [rd_port_cross_exch_prod_alt_name] (
   [alt_name_index] [int] NOT NULL ,
   [portfolio_cross_exchange_product_id] [int] NOT NULL ,
   [alternative_name] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
   CONSTRAINT [PK_rd_port_cross_exch_prod_alt_name] PRIMARY KEY  CLUSTERED
   (
      [alt_name_index],
      [portfolio_cross_exchange_product_id]
   )  ON [PRIMARY] ,
   CONSTRAINT [FK_rd_port_cross_exch_prod_alt_name_rd_portfolio_cross_exchange_product] FOREIGN KEY
   (
      [portfolio_cross_exchange_product_id]
   ) REFERENCES [rd_portfolio_cross_exchange_product] (
      [id]
   )
) ON [PRIMARY]
GO


When I try to save the entry in the master table is created, but nothing is added to the child table. I've atteached a debugger to the string[] property and that is beig accessed 3 time from external code, NHibernate.

I have tried changing my child DB table to have an extra column set as an identity column and PK, just in case NHibernate has difficulties with the combined PK in the definition above. I've tried setting my debugger to brak when an exception is thrown, but no exception is being thrown.

I am using NHibernate 1.0.4, against MS SQL server 2000

Any ideas to what I am doing wrong, coz I can't work it out


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.