nhibernate-mapping

NHibernate MappingException: Could not compile the mapping document

戏子无情 提交于 2019-12-21 04:26:26
问题 On my dev web app NHibernate is working just dandy. When I precompile and deploy the site, I get a MappingException when the SessionFactory is created. Here's some info from the trace: NHibernate.Cfg.Environment 2010-07-15 09:20:59,577 [7] INFO NHibernate.Cfg.Environment [(null)] - NHibernate 2.1.2.4000 (2.1.2.4000) 0.452436832055471 0.232383 NHibernate.Cfg.Environment 2010-07-15 09:20:59,718 [7] INFO NHibernate.Cfg.Environment [(null)] - Bytecode provider name : lcg 0.522780409241957 0

many-to-one with multiple columns

自古美人都是妖i 提交于 2019-12-20 21:56:20
问题 I have a legacy data base and a relation one-to-one between two tables. The thing is that relation uses two columns, not one. Is there some way to say in nhibernate that when getting a referenced entity it used two columns in join statement, not one? I have a similar table structure TaskProgress ProgressId TaskId AssignmentId UserId Tasks TaskId AssignmentId TaskName Each task can be asigned in different assignments. That mean that unique task for task progress can be founded only by

many-to-one with multiple columns

半腔热情 提交于 2019-12-20 21:56:14
问题 I have a legacy data base and a relation one-to-one between two tables. The thing is that relation uses two columns, not one. Is there some way to say in nhibernate that when getting a referenced entity it used two columns in join statement, not one? I have a similar table structure TaskProgress ProgressId TaskId AssignmentId UserId Tasks TaskId AssignmentId TaskName Each task can be asigned in different assignments. That mean that unique task for task progress can be founded only by

nhibernate custom collection handling

孤街醉人 提交于 2019-12-20 17:29:54
问题 I have a working one to many relationship (NOT bbidirectional) where Resource has a set of many Allocations implented as shown below. The domain needs to do more with the collection of allocations that just manage it with AddAllocation, RemoveAllocation, etc. So from an object perspective, I'd like to put that extra logic that is not persistent related into a different class, AllocationCollection, and make that extra class transparent to NHib. I'd also like to flesh out the responibilities of

Hibernate Criteria Return parent record that have one-to-one child record not null?

心已入冬 提交于 2019-12-20 06:39:51
问题 I have a one-to-one relation like this The Parent @JsonAutoDetect @Entity @Table(name = "Parent") public class Parent{ private Integer id; private Child child; @Id @GeneratedValue(strategy= GenerationType.AUTO) @Column (name="idparent") public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "parent") @JoinColumn(name="idchild", nullable=true) public Child getChild() { return child; } public

NHibernate Mapping Breaks when upgrading to NHibernate 3.1

陌路散爱 提交于 2019-12-20 04:52:17
问题 I just recently upgraded to FluentNHibernate 1.2 which uses NHibernate 3.1. After upgrading some of my old mappings are not working. I've been having a hard time figuring out why, I thought maybe someone here could help. I have 3 classes, Practice, Drill, and PracticeDrill. A Practice has many Drills and a Drill can be in many Practices. PracticeDrill is the table that joins them and also includes an Order. Here are my C# POCOs: public class PracticeDrill { public virtual Practice Practice {

How to eager load objects in a list/collection?

江枫思渺然 提交于 2019-12-20 04:16:37
问题 I have the following query: ObjectB objectBAlias = null; ObjectC objectCAlias = null; var query = session.QueryOver<ObjectA>(); var results = query .JoinAlias(x => x.listOfBs, () => objectBAlias) .JoinAlias(x => objectBAlias.ObjectC, () => objectCAlias) .TransformUsing(new DistinctRootEntityResultTransformer()) .List<ObjectA>(); class ObjectA { IList<ObjectB> listOfBs; } class ObjectB { ObjectA a; ObjectC c; } class ObjectC { int x; } ObjectA has a many-to-many relationship to ObjectC with

NHibernate ClassMap get column name for property

半城伤御伤魂 提交于 2019-12-20 03:18:04
问题 I have ClassMap and entity. In code I would like to get column names for properties in entity. Any Idea? public class AccountToDepotMap : ClassMap<AccountToDepot> { public AccountToDepotMap() { Table("COPS_WPA_ACCOUNT_DEPOT"); Id(t => t.RecId, "REC_ID"); Map(t => t.RecordDate, "REC_DATE"); Map(t => t.DepotId, "WPA_DEPOT_ID"); Map(t => t.AccountId, "WPA_ACCOUNT_ID"); Map(t => t.IsActive, "ISACTIVE").CustomType<YesNoType>(); } } public class AccountToDepot { public virtual long RecId { get; set

NHibernate Collection Sub Query

喜你入骨 提交于 2019-12-20 03:15:03
问题 Is there a way to add criteria to a mapping for NHibernate? public class Course { public IList<Participant> Participants { get; set; } public IList<Participant> ActiveParticipants { get; set; } } The second property, ActiveParticipants should be a list of participants where their "Status" is set to "Active". Otherwise, is there a way to post process the class, but still maintaining Lazy Loading, as sometimes the "ActiveParticipants" property will not be used. The reason it needs to be like

Fluent NHibernate and computed properties

南楼画角 提交于 2019-12-19 09:06:21
问题 I'm using Fluent NHibernate, and auto-mapping the classes. I have a computed property in a class along the lines of public virtual DateTime? LastActionTimeStamp { get { return Actions.Count == 0 ? null : Actions.OrderByDescending( a => a.TimeStamp).ElementAt(0).TimeStamp; } } This wasn't mapped with the rest of the properties, so I couldn't use it in an ICriteria restriction. I added an empty setter (as I read somewhere that doing so would include it in the mapping, which it does), but now I