|
|
|
If you had a patch, we could discuss it.
Hi Sergey, I have attached a patch against r2594. It includes tests ported over from H3 plus some others. I couldn't get the "optional" attribute to work. Frankly, I am not too sure how it is supposed to behave. Can you shed some light on this?
By the way, I would consider this patch incomplete because of the "optional" attribute described above. I also need to write some tests to test the "inverse" attribute. Thanks in advance. Thanks for the patch, Karl. I will only add this after 1.2 final is released though.
I need a clarification on the "inverse" attribute. Assume the following mapping:
<class name="Person" ...> ... <join table="Stuff" inverse="true"> <key .../> <property name="StuffName"/> </join> </class> I understand from the H3 documentation that "If enabled, Hibernate will not try to insert or update the properties defined by this join". However, when a Person is deleted, should the delete cascade down to the "Stuff" table? Judging from the code, delete will not cascade to inverse joins.
Updated the last patch. This one was created from r2680.
This patch added tests to test the "inverse" attribute. When "inverse" is true, the joined table is not updated, inserted to, or deleted from (see previous comment). Can someone confirm that it behaves the same way in Hibernate 3.2 please? Thanks. Hello Karl,
I cannot tell you if this works as it should in 3.2, but i am going to put the patch in the version of nhibernate we use currently and let you know how this goes ;) Taavi Changing fix version to TRUNK since this wasn't applied to the 1.2.x branch.
This doesn't seem to work for composite keys.
I tried a mapping file similar to the one below, and it produced an error in NHibernate.SqlCommand.ANSIJoinFragment.AddJoin because that method only had one element in the pkColumns array, as opposed to the two in the fkColumns array. Thanks, Andrew <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Core" namespace="Core.Domain"> <class name="Employee" table="DLEPAPPT" lazy="false" where="emp_number = emp_number_main"> <composite-id name="Pk" class="EmployeePk"> <key-property name="Company" column="coy" /> <key-property name="EmpNumber" column="emp_number_main" /> </composite-id> <property name="StartDate" column="emp_start_date" /> <join table="DLEPEM"> <key> <column name="coy" /> <column name="emp_number" /> </key> <property name="FirstName" column="emp_first_name" /> <property name="Surname" column="emp_surname" /> <property name="OtherNames" column="emp_other_names" /> <property name="Title" column="emp_title" /> </join> </class> </hibernate-mapping> Andrew, may be you need to use <key-many-to-one> as in the following?
<class name="Employee" ...> <composite-id name="Pk" class="EmployeePk"> <key-many-to-one name="Company" column="coy" /> <key-property name="EmpNumber" column="emp_number_main" /> </composite-id> ... </class> Can you give that a try? Hi Karl
Thanks for looking into this. Changing the mapping to "key-many-to-one" doesn't help in this situation. The "Company" and "EmpNumber" properties are not complex types - they're just ints and Nhibernate now complains that "An association from the table DLEPAPPT refers to an unmapped class: Int32". Thanks, Andrew Karl Chu,
Can you regenerate the patch from the trunk, I have been unable to apply it. Hi Ayende, I recreated the patch against r2826 (attached).
There was also a problem with NHibernate.JetDriver.JetCaseFragment (or is it really a problem of the base class NHibernate.SqlCommand.CaseFragment?) At any rate, the easiest thing for me to do so I can run the tests again before re-uploading the patch was to change JetCaseFragment. I will upload a separate patch because it really isn't an issue having to do with this <join> patch. I applied the first patch, the JetCaseFragement was already solved by Sergey, I think.
Thanks! Using this within a subclass causes an exception: It seems to want to apply this join to the base class:
My mapping: <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Narrowstep.Entities" namespace="Narrowstep.Entities"> <subclass discriminator-value="5" extends="Vlip" name="DownloadPackage" > <join table="dspChannelServer"> <key> <column name="VlipID" /> </key> <property name="IsEnabled" column="IsEnabled"/> <many-to-one name="PaymentRule" column="PBRuleID" class="PaymentRule" foreign-key="VlipID" /> </join> </subclass> </hibernate-mapping> However, when I try to access the base class, it tries to bring back the extended properties of the subclass and this throws a SqlException: SQL Generated: SELECT vlip0_.PKid as PKid3_0_, vlip0_.ProjectID as ProjectID3_0_, vlip0_.MetaDataID as MetaDataID3_0_, vlip0_.Title as Title3_0_, vlip0_.Abstract as Abstract3_0_, vlip0_.ShortAbstract as ShortAbs7_3_0_, vlip0_.Author as Author3_0_, vlip0_.Copyright as Copyright3_0_, vlip0_.Keywords as Keywords3_0_, vlip0_.Series as Series3_0_, vlip0_.Episode as Episode3_0_, vlip0_.Part as Part3_0_, vlip0_.VlipLength as VlipLength3_0_, vlip0_.StartTime as StartTime3_0_, vlip0_.Duration as Duration3_0_, vlip0_.CreateDate as CreateDate3_0_, vlip0_.EventDate as EventDate3_0_, vlip0_.ExpiryDate as ExpiryDate3_0_, vlip0_.LinkUrl as LinkUrl3_0_, vlip0_.ThumbID as ThumbID3_0_, vlip0_.ThumbUrl as ThumbUrl3_0_, vlip0_.Notes as Notes3_0_, vlip0_.AudioInfo as AudioInfo3_0_, vlip0_.VideoInfo as VideoInfo3_0_, vlip0_.Rating as Rating3_0_, vlip0_.RatingDescription as RatingD27_3_0_, vlip0_1_.IsEnabled as IsEnabled1_0_, vlip0_1_.PBRuleID as PBRuleID1_0_, vlip0_.ContentTypeID as ContentT2_0_ FROM Vlips vlip0_ WHERE vlip0_.PKid=@p0; @p0 = '40845' Exception: System.Data.SqlClient.SqlException: The multi-part identifier "vlip0_1_.IsEnabled" could not be bound. As you can see it is not included in the FROM clause, but the column names are incorrectly included. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This would be a very valuable addition and a long waited addition.
And to sum things up, great work with the API !!! Love to use it !!