nhibernate-mapping

Nesting multiple entities hibernate giving issues

非 Y 不嫁゛ 提交于 2021-02-11 18:19:44
问题 I am having an issue with mapping a 3rd level entity please consider the following code: Parent Entity : @Entity @Table(name = "Tree") public class Tree { @Id @Column(name="Tree_Id") @GeneratedValue(strategy = GenerationType.Identity) private Integer id; @OneToMany(mappedBy = "parentTree", cascade = CascadeType.ALL, orphanRemoval = true) private Set<Branch> branches; //Getters And Setters public Branch addBranch(Branch branch) { getBranch().add(branch); branch.setTree(this); return branch; }

How to auto generate IDs in NHibernate

混江龙づ霸主 提交于 2021-02-07 03:33:05
问题 How can I make NHibernate autogenerate unique IDs for a table? The IDs can be any long values, as long as each one is only used once. My current mapping looks like this: <id name="Id"> <generator class="increment"/> </id> This creates increasing IDs starting at 1, but it resets to 1 at each application startup. So the after each restart, the first element that is stored gets the Id 1 and the previous Id 1 element is deleted (not what I want). Edit: The reason for this is that I used

How to auto generate IDs in NHibernate

青春壹個敷衍的年華 提交于 2021-02-07 03:31:27
问题 How can I make NHibernate autogenerate unique IDs for a table? The IDs can be any long values, as long as each one is only used once. My current mapping looks like this: <id name="Id"> <generator class="increment"/> </id> This creates increasing IDs starting at 1, but it resets to 1 at each application startup. So the after each restart, the first element that is stored gets the Id 1 and the previous Id 1 element is deleted (not what I want). Edit: The reason for this is that I used

Unable to cast object of type NHibernate.Collection.Generic.PersistentGenericBag to List

淺唱寂寞╮ 提交于 2020-03-08 04:57:46
问题 I have a class called ReportRequest as: public class ReportRequest { Int32 templateId; List<Int32> entityIds; public virtual Int32? Id { get; set; } public virtual Int32 TemplateId { get { return templateId; } set { templateId = value; } } public virtual List<Int32> EntityIds { get { return entityIds; } set { entityIds = value; } } public ReportRequest(int templateId, List<Int32> entityIds) { this.TemplateId = templateId; this.EntityIds = entityIds; } } It is mapped using Fluent Hibernate as:

MappingException: No persister for - NHibernate - Persisting an Adapter [duplicate]

我与影子孤独终老i 提交于 2020-02-15 19:59:59
问题 This question already has answers here : NHibernate.MappingException: No persister for: XYZ (15 answers) Closed 5 years ago . Well, I googled a lot, and found the same advices all there (set hbm as Embedded Resource, add hbm at hibernate.cfg, etc..), and despite of them, I still not get it. Let me explain: I wrote a Communication Dll for a ticket gate device, and there I have a configuration model class, that I use to configure that device through TCP/IP. But now, I have to persist this

MappingException: No persister for - NHibernate - Persisting an Adapter [duplicate]

岁酱吖の 提交于 2020-02-15 19:58:47
问题 This question already has answers here : NHibernate.MappingException: No persister for: XYZ (15 answers) Closed 5 years ago . Well, I googled a lot, and found the same advices all there (set hbm as Embedded Resource, add hbm at hibernate.cfg, etc..), and despite of them, I still not get it. Let me explain: I wrote a Communication Dll for a ticket gate device, and there I have a configuration model class, that I use to configure that device through TCP/IP. But now, I have to persist this

Fluent-Nibernate with wpf: Convention to use uNhAddIns…ObservableListType<T> as default?

放肆的年华 提交于 2020-02-03 10:02:05
问题 I am trying to use Fluent-Nibernate with wpf that require Observable collections (implement the INotifyCollectionChanged interface). At uNHAddins: Unofficial addins for NHibernate i found the uNhAddIns.WPF.Collections.Types.ObservableListType<T> that implements INotifyCollectionChanged . It can be configured in Fluent-Nibernate like this namespace FluentNHibernateTutorial.Mappings { public class StoreMap : ClassMap<Store> { public StoreMap() { Id(x => x.Id); Map(x => x.Name); HasManyToMany(x

Fluent-Nibernate with wpf: Convention to use uNhAddIns…ObservableListType<T> as default?

不羁的心 提交于 2020-02-03 10:00:08
问题 I am trying to use Fluent-Nibernate with wpf that require Observable collections (implement the INotifyCollectionChanged interface). At uNHAddins: Unofficial addins for NHibernate i found the uNhAddIns.WPF.Collections.Types.ObservableListType<T> that implements INotifyCollectionChanged . It can be configured in Fluent-Nibernate like this namespace FluentNHibernateTutorial.Mappings { public class StoreMap : ClassMap<Store> { public StoreMap() { Id(x => x.Id); Map(x => x.Name); HasManyToMany(x

Generate table indexes using Fluent NHibernate

血红的双手。 提交于 2020-01-28 17:59:44
问题 Is it possible to generate table indexes along with the rest of the database schema with Fluent NHibernate? I would like to be able to generate the complete database DDL via an automated build process. 回答1: In more recent versions of Fluent NHibernate, you can call the Index() method to do this rather than using SetAttribute (which no longer exists): Map(x => x.Prop1).Index("idx__Prop1"); 回答2: Do you mean indexes on columns? You can do it manually in your ClassMap<...> files by appending