Fluent NHibernate Not Mapping Child Rows To A Collection Property (DB2 Database)
Nov 4, 2011
The tables described herein both utilize composite keys. I have a parent table that stores eligibility information per "case". The child table stores eligibility information regarding each individual associated with the case. The child records are differentiated by pin number to make them unique in the child table only.
I am using NHibernate v3.1 with Fluent NHibernate v1.2, both acquired via NuGet packages. The entities are mapped in using the Fluent NHibernate auto-mapper functionality. Any custom mapping is done in the mapping override method for each entity.
Another thing to know is that these tables do not have a "primary key" defined in DB2. They only have "unique keys", which are what you see in the composite key definition below (see code).
T0026_AG_ELIG is the name of the parent table and the corresponding POCO class.
T0265_AG_IN_ELIG is the name of the child table and the corresponding POCO class.
Problem:
The problem is that when I execute the query, all the data is queried, the parent record is successfully mapped to the class, but the returned child rows do not map into the collection on the parent class. NHibernate does generate the queries for the parent and child data. When I execute my own query against the database, the correct data for the conditions does come back. For some reason, the child records are just not being bound to the property on the parent (T0026) class.
Question:
What do I need to do to get the multiple rows coming back from T0265_AG_IN_ELIG to map to their corresponding class and load properly into the specified collection property on the parent class (T0026_AG_ELIG)?
Collection Property of Parent (T0026_AG_ELIG):
Public Overridable Property IndividualEligibilityRecords As IList(Of T0265_AG_IN_ELIG)
Mapping Override for Parent (T0026_AG_ELIG):
mapping.CompositeId() _
I am using Fluent NHibernate to map an Oracle database. It is a legacy database so I cant really change everything I want.There is a GUID field, but the keys are still composite (I will change this as soon as I can so that the keys are not composite, but I cant do it right now). The GUID is a VARCHAR2 field with this layout: 551608b1-275d-49f6-9561-44d01aacf23f. The GUID is not added by a sequence in Oracle, but inserted from code (C# or VB.net)[code]Is the problem that I dont use a sequence to generate my GUID? How can I overcome this?
I would like to ask if you can use VB.NET for NHibernate and Fluent Nhibernate?I have searched the web, but I can't seem to get a detailed or explicit statement that tells that one can use VB.NET for NHibernate and with Fluent.
Many of the samples in the NHibernate site are made in C#. That's why I was wondering if I can't use VB.NET when using NHibernate.
If I have a parent object (Parent) which has a List(Of Child) objects as a many-one relationship. Is it possible to return a Parent with a subset of it's child objects (eagerly loaded)? I am using VB and Criteria.
e.g. If Parent 1 has 50 children (20 type X 30 type Y) and I want to return the Parent with a collection containing only type X.
I only want a collection with a size of 20 with it's eagerly loaded children?
I am having some redundant primary key issues.I have an Item which contains many reports. I have mapped them as shown below. I can do Session.QueryOver(Of Item).List and there are no extra columns generated. I can also do Session.QueryOver(Of Report).List and there are no extra columns generated.
However, once I try to traverse the relationship from Item to Reports, I get the SQL query shown below. Can anyone tell me why?
Because there is so little information about VB.Net and (Fluent) NHibernate to be found, I decided to write this question to all other developers finding themselves looking for more information.On of the things i had to struggle with was how to Ignore properties in NHibernate.The reason i had to ignore properties was because we used a Webserivce which cannot serialize Interface classes (ILists). Which are used a lot with NHibernate.
I've been using c# for the past year and I enjoy the power you get with Fluent NHibernate. One question that I get from friends is "nice but how can vb.net programmers use this?"So for example- the below is a c# mapping class. How would someone do this with vb.net?
public class PostMap : ClassMap<post> { public PostMap() { Table("Posts");
I am using Fluent NHibernate to map out an existing database. For this reason - automapping isn't an option for me.How do I tell NHibernate not to map certain properties? Many of them are read-only, and the others do not need to be persisted for other reasons.
I am writing this in VB.Net.I get the typical error message:"The following types may not be used as proxies should be 'public/protected virtual' or 'protected internal virtual'"I have purposely not made my objects Overridable (equivalent to virtual in C#) because I do not want NHibernate to touch them.
Question: I get an exception serializing this class to a nHibernate xml file ({"Could not determine type for: System.Drawing.Image, System.Drawing, for columns:NHibernate.Mapping.Column(Settings)"}).
using System; using System.Collections.Generic; using System.Text;
I have a read-only mssql-view, and I want to map it to nhibernate (using hbm.xml files). The view is a select that joins two tables. For give an abstract-insight, the select is something like this:
SELECT A.Id As A_ID, B.Id As B_ID, A.AttributeA, B.AttributeB, FROM A INNER JOIN B ON A.Id = B.RootID
It's a one-to-many relationship between A and B (B entries are dependant/leafs of A entries).
I'm using nhibernate's hbm.xml files, and I can't make it to work. I'd gladly appreciate if someone can enlight me of the kind of XML that I have to use, I guess that as my view has no ID, I have to create a composite-nhibernate id (wich will be the ids os A and B together) but I couldn't make it to work. Also the view is READ ONLY so I think that should make the solution easier.
I'm a C# programmer constrained to write VB.NET code.While exploring NHibernate further for my current client, I encountered FluentNHibernate, which I find real attractive.But now, I wonder how to "translate" this C# code for component mapping into VB.NET code:
what I miss is how to continue with the brackets in VB.NET, since there's no Begin End keywords or so.
EDIT 1: Following Mr. JaredPar instructions, I figured that his solution might work. If we take the time to read his answer, we may notice that we both don't know what the MType is within his solution. I might have found out that the MType is:
Thus, TComponent is, from my understanding, an anonymous type that I shall parameter to use. From this point of view, since I wish to map the properties of my Address object, replacing TComponent in my help method signature seems not to work.
Private Sub MapAdresseHelper(Of Adresse)(ByVal a As FluentNHibernate.Mapping.ComponentPart(Of Adresse)) a.Map(Function(m) m.Number) a.Map(Function(m) m.Street).Length(50)
[code]...
The error I get is that my Address class doesn't have a property member named Street, for instance. It sees my Address type, it recognizes it, but it seems buggy somehow. I guess VBNET is poorly designed for lambda expressions and is less evolved than C#?
Basically, I wish to fetch a filtered set of objects from the database (Oracle 9.2) based on the id property of the object PsalertsEvent. The code being executed is:
Public Overloads Function GetAll(ByVal laterThan As Long, ByVal filteredPsalertsEvents As IList) As IList Implements IPsalertsEventRepo.GetAll 'Get all psalerts events with an ID greater then the specified laterThan parameter filteredPsalertsEvents = MyBase.NHibernateSession.CreateQuery("from PsalertsEvent p where p.id > " & laterThan).List
I get the following string expression provided:"ChildObject.FullName" ...where ChildObject is an instance property on the MyObject1 type.ChildObject has a property named "FullName" and I want to sort a collection of type "MyObject1" based on this child properties "FullName" value.
I can do this all day long on properties directly on MyObject1 but I run into 2 challanges when doing it on a child instance and I can't get all the pieces working. The main 2 challanges are:
MyObject1 has a few different child property types so I can't hardcode the type for ChildObject. The string could be of any type.The sort expression is a String and not a known type.Above the value returned from the last line in the expression (if I run the code outsode the OrderBy method, does provide me the 'FullName' information I need. So the code must be close, but it still does not work.
Any ideas on how I can accomplish this? What I am trying to prevent is hardcoding a series of 'If' blocks on the child's type to then hardcode in its type to the sort or OrderBy method.
Having successfully tried out nHibernate, I would now like to try using Fluent for mapping. My main project is in vb.net but I would really like to use c# for the mappings since the lambda expression capability makes it much cleaner. Can you have a separate project/assembly for your mapping files without creating a circular dependency with domain objects?
Having successfully tried out nHibernate, I would now like to try using Fluent for mapping. My main project is in vb.net but I would really like to use c# for the mappings since the lambda expression capability makes it much cleaner. Can you have a separate project/assembly for your mapping files without creating a circular dependency with domain objects?
I have a situation where a class's properties are being exported/imported from an Excel sheet. Each property is in a specific column, so I want to make a mapping between each property and column # (a Dictionary collection would be sufficient). That way I can just loop through each property and/or column in the dictionary when read/writing data (maybe something like Class1.PropertyA = ws.Cells(curRow, Propto ColDictionary(PropertyA???).value). But, you obviously can't treat properties like other value types, so I don't know how I would store a property in a dictionary for this purpose. So could this sort of thing be achieved via reflection, or am I off-track?
I have issue with a Nhibernate projection list, It keeps saying it Could not find a setter for property 'Commname' in class 'Label6.Domain.Product' or could not resolve property "pl.commname" the property "commname" is a part of the object productslangs.
My product object looks like this: Public Overridable Property Latinname() As System.String Get Return _Latinname End Get Set(ByVal value As System.String) [Code] .....
I'm working on a project to replace ADO.NET data access logic using NHibernate where we're not able to map the entire domain model at once. This means we'll have domain classes with property mappings to other domain classes that aren't yet mapped with NHibernate.
Consider a Person class with an Address property (Address being a domain object without an NH mapping and Person being the class I'm mapping). How can I include Address in the Person mapping without creating an entire mapping for Address? Is it possible to call legacy (ADO.NET) data access logic from a custom PropertyAccessor? If so, is it reasonable?
*I asked this within another question here but didn't get a response. I'm hoping to get one in a more concise question.
I am working on Treeview control and Gridview Control VB.NET08. In the Treeview i have Parent and Child Nodes. Like: [Code] Comparing the Parent Node text and first two digits in the Column values. I want to add rows inbetween the gridview rows based on the parent and Child Nodes. If i expand the First Parent Node Called "31" then according to the Number of Child Nodes (for first parent node(31) there are 5 child nodes.) add rows in the gridview.
These New rows should be add under the 31-xxxx. If i expand the 32 Parent Node based on number of Child Nodes, add rows under the 32-xxxx. [Code] I am getting the rows in the end of the Gridrow not in the Specific row.
how to add Rows programmatically to the DataGridView's rows collection when the control is data-bound? here is my code but i got error as "Rows cannot be programmatically added to the DataGridView's rows collection when the control is data-bound? "
I just read this article about the Entity Framework 4 (actually version 2).Entity Framework seems to offer a huge improvement over its first release. Thus, I have never ever used EF in any project, since I think EF is not mature enough in comparison to NHibernate.NHibernate and its current contributions of FluentNHibernate and Linq for NHibernate by Ayende RahienMy feeling is that Microsoft is solely trying to gain terrain it has lost in favor of NHibernate when the 2nd version of NHibernate came out.Nevertheless, my concerns are the followings (not in particular order):Will EF4 tend to be less XML-verbose?Will EF4 be compatible with other underlying datastore than just SQL Server?What are the greatest benefits of going with EF4 instead of FluentNHibernate or NHibernate itself.
NHibernate is a great tool, I guess everyone agrees. Due to its predecessor Hibernate, we may easily find documentions and tutorials and sample applications to get acquainted with it. This is not the case for FluentNHibernate. Particularly as per the project I'm working on right now which demands that I investigate further about NHibernate and its options (FluentNHibernate for instance) in order to document the rules of usage and the best practices of NHibernat and FluentNHibernate technology. Thus, being handcuffed with VB.NET, being a C-Style developer, I can't find some syntax equivalencies in VB.NET for the examples provided, though I made I way so far
Can anyone tell me why "Rows cannot be programmatically added to the DataGridView's rows collection when the control is data-bound." I keep getting an error "Invalid Operation Exception was Unhandled" error. All I am attempting to do is allow the user to select products from a list(or a second datagridview) and have it added to the datagridview so they do not have to type in every cell since the other cells are not visible because they do not purtain to their needs. Plus they will be able to save all items at the same time.
I have two datagridview's both are databound. First one shows items for sale and the second stores all the items that were sold. I am trying too transfer selected rows from one to the other but no matter what I keep getting told "Rows cannot be programmatically added to the DataGridView's rows collection when the control is data-bound."
I've reviewed the links that were offered and don't find an answer. Neither has a lot of searching helped, probably because I can't think of a reasonably short way to ask the question. I hope that I've at least found the proper forum and category.
In my VB 2010 code, I've defined a structure that has about 30 elements. I want to sum the properties (they are all singles) of two members of the corresponding collection. I understand that I can do something like:
member1.property1=member2.property1+member 3.property1 for the entire set of properties of member2 and member3 to produce a completely defined member1 What I wonder is whether or not there is a way that uses fewer lines of code - I know that I can't do:member1=member2+member3, for example.
I have 1 form as parent MDI (frmParent.vb) and have 2 child form (frmChild01.vb & frmChild02.vb).the code for parent form as per below.
Public Class frmParent Private Sub OpenChild01ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenChild01ToolStripMenuItem.Click Dim child01 As frmChild01
[code]....
My problem is how can I set label1.text in frmChild02.vb when user click button1 in frmChild01.vb
I have a form with a button that says "Open CSV".I want to be able to click that button. Then browse for a .CSV file, and after I select the file, populate a combobox with all of the headers of the .CSV.I would then be mapping these headers to fields in my database, then import the .CSV data into my database.
way to return a collection of treenodes which are children of a selected node? I can't find on MSDN a object of treenodes that is a collection of childnodes.
I have two treeviews, and I am writing code that will copy treenodes from one treeview to another treeview if it is selected. If a parent node is selected, I would also like to copy over all the children. If it is just a childnode, then I would like to copy just that.
Here is what I have so far.
Dim treeobj As TreeNode treeobj = TreeView2.Nodes.Add(TreeView1.SelectedNode.Text) If TreeView1.SelectedNode.Parent.Index.ToString Is System.DBNull.Value Then