ComponentMap (multiple instances of the same component in an entity)
Hello,
I’m trying to map a multiple instances of the same component in an entity, writing something like that:
public class BugDesc
{
public int Desc1 { get; set; }
public int Desc2 { get; set; }
public int Desc3 { get; set; }
}
public class Bug
{
public Int64 ID { get; set; }
public BugDesc BugDesc1 { get; set; }
public BugDesc BugDesc2 { get; set; }
}
public class BugDescMap : ComponentMap<BugDesc>
{
public BugDescMap()
{
Map(x => x.Desc1).Column("DESC1");
Map(x => x.Desc2).Column("DESC2");
Map(x => x.Desc3).Column("DESC3");
}
}
public class BugMap : ClassMap<Bug>
{
public BugMap()
{
Table("BUG");
Id(x => x.ID).Column("BUG_ID")
.GeneratedBy.Sequence("BUG_SQ");
Component(x => x.BugDesc1)
.ColumnPrefix("FIRST_");
Component(x => x.BugDesc2)
.ColumnPrefix("SECOND_");
}
}
But it doesn't work, I have an exception during the saving of my entity: "Invalid index 4 for this OracleParameterCollection with Count=4" (I think, this is because of multiple presence of property in the result mapping). When I try to load already existing entity it generates such SQL: "Select BUG_ID, SECOND_FIRST_DESC1, SECOND_FIRST_DESC2, SECOND_FIRST_DESC3 from BUG" and of course can’t find such fields in the table. When I use one instance of component it works fine.
Comments are currently closed for this discussion. You can start a new one.
Support Staff 2 Posted by James Gregory on 17 Mar, 2010 11:41 AM
That's pretty weird. I'll investigate this later on today.
3 Posted by Dmitry on 26 Mar, 2010 11:03 AM
Hello, is where are something new in this question?
4 Posted by Dmitry on 04 May, 2010 10:38 AM
Hello! Sorry, for my importunity, did you investigate this problem?
5 Posted by Franck on 11 May, 2010 04:18 PM
Hi all,
I'm getting the same issue with build 1.0.0.650.
6 Posted by Franck on 12 May, 2010 07:56 AM
Produce the following SQL
CREATE TABLE "Store" (Id integer, ADDR2_ADDR1_NUMBER INTEGER, ADDR2_ADDR1_STREET TEXT, ADDR2_ADDR1_CITY TEXT, ADDR2_ADDR1_POSTCODE TEXT, Name TEXT, primary key (Id));
Is there a workaround ?
7 Posted by Dmitry on 12 May, 2010 11:54 AM
You can do somthing like this:
public class StoreMap : ClassMap {
}
But of couse it will be great to use standart functionality for such things and I hope this issue will be fixed in the nearest future.
8 Posted by Franck on 12 May, 2010 01:12 PM
Thanks Dmitry
I Hope it will be fixed soon because ComponentMap is a great feature
Support Staff 9 Posted by James Gregory on 15 May, 2010 10:17 PM
FYI, this issue only presents itself when you specify the column names explicitly; if you don't do that, it should work fine.
I'm investigating a fix right now.
Support Staff 10 Posted by James Gregory on 15 May, 2010 11:00 PM
I've committed a fix for this (revision
e8f13b0
). Feedback would be appreciated.11 Posted by Dmitry on 17 May, 2010 11:29 AM
Does the latest build (#677) contain this changes? The question is because of I get it but the problem remained.
Support Staff 12 Posted by James Gregory on 17 May, 2010 01:32 PM
667 should fix the issue. I was able to create the problem, then fixed it. Could you provide us with an updated example using the latest binaries?
13 Posted by Franck on 17 May, 2010 02:00 PM
I've replaced with version 677 and it works for me.
Thanks for the fix
James you make a great job for the community
14 Posted by Dmitry on 17 May, 2010 03:46 PM
I'm sorry, it was my mistake.
Thanks a lot for the fix.
Support Staff 15 Posted by James Gregory on 17 May, 2010 04:02 PM
No problem, glad it worked.
James Gregory resolved this discussion on 17 May, 2010 04:02 PM.