Search Results

Search found 2353 results on 95 pages for 'nhibernate validator'.

Page 14/95 | < Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >

  • How do I change a child's parent in NHibernate when cascade is delete-all-orphan?

    - by Daniel T.
    I have two entities in a bi-directional one-to-many relationship: public class Storage { public IList<Box> Boxes { get; set; } } public class Box { public Storage CurrentStorage { get; set; } } And the mapping: <class name="Storage"> <bag name="Boxes" cascade="all-delete-orphan" inverse="true"> <key column="Storage_Id" /> <one-to-many class="Box" /> </bag> </class> <class name="Box"> <many-to-one name="CurrentStorage" column="Storage_Id" /> </class> A Storage can have many Boxes, but a Box can only belong to one Storage. I have them mapped so that the one-to-many has a cascade of all-delete-orphan. My problem arises when I try to change a Box's Storage. Assuming I already ran this code: var storage1 = new Storage(); var storage2 = new Storage(); storage1.Boxes.Add(new Box()); Session.Create(storage1); Session.Create(storage2); The following code will give me an exception: // get the first and only box in the DB var existingBox = Database.GetBox().First(); // remove the box from storage1 existingBox.CurrentStorage.Boxes.Remove(existingBox); // add the box to storage2 after it's been removed from storage1 var storage2 = Database.GetStorage().Second(); storage2.Boxes.Add(existingBox); Session.Flush(); // commit changes to DB I get the following exception: NHibernate.ObjectDeletedException : deleted object would be re-saved by cascade (remove deleted object from associations) This exception occurs because I have the cascade set to all-delete-orphan. The first Storage detected that I removed the Box from its collection and marks it for deletion. However, when I added it to the second Storage (in the same session), it attempts to save the box again and the ObjectDeletedException is thrown. My question is, how do I get the Box to change its parent Storage without encountering this exception? I know one possible solution is to change the cascade to just all, but then I lose the ability to have NHibernate automatically delete a Box by simply removing it from a Storage and not re-associating it with another one. Or is this the only way to do it and I have to manually call Session.Delete on the box in order to remove it?

    Read the article

  • What problem does NHibernate solve?

    - by SLC
    I've seen some jobs that require nhibernate knowledge, as well as numerous questions on stack. I found another question that pointed me to Summer Of NHibernate and I am watching the videos now. However it has no introduction explaining why NHibernate was created and what problem is solves. By looking on wikipedia, I can see vaguely what it does, but to me it looks like .NET already has the entity framework which seems to do the same thing. Can anyone clarify why nhibernate exists?

    Read the article

  • How do I map to a parent or child in the same table with NHibernate?

    - by adolfojp
    Lets suppose that I have a Category table with a column that holds the id of a parent or child category from the same table. This design would allow me to have unlimited levels of Categories, or unlimited levels in a thread, for example. How can I map this relationship with NHibernate? Are there any disadvantages or warnings that I should take into consideration when doing this?

    Read the article

  • How to map auto property private set with NHibernate?

    - by Michael Teper
    Suppose I have this class: public class GroceryListItem() { public GroceryList { get; private set; } public GroceryListItem(GroceryList groceryList) { GroceryList = groceryList; } } What is the NHibernate mapping file access strategy for this scenario? (i.e. <one-to-many name="GroceryList" column="XXX" access="?????" />)

    Read the article

  • Custom validator not invoked when using Validation Application Block through configuration

    - by Chris
    I have set up a ruleset in my configuration file which has two validators, one of which is a built-in NotNullValidator, the other of which is a custom validator. The problem is that I see the NotNullValidator hit, but not my custom validator. The custom validator is being used to validate an Entity Framework entity object. I have used the debugger to confirm the NotNull is hit (I forced a failure condition so I saw it set an invalid result), but it never steps into the custom one. I am using MVC as the web app, so I defined the ruleset in a config file at that layer, but my custom validator is defined in another project. However, I wouldn't have thought that to be a problem because when I use the Enterprise Library Configuration tool inside Visual Studio 2008 it is able to set the type properly for the custom validator. As well, I believe the custom validator is fine as it builds ok, and the config tool can reference it properly. Does anybody have any ideas what the problem could be, or even what to do/try to debug further? Here is a stripped down version of my custom validator: [ConfigurationElementType(typeof(CustomValidatorData))] public sealed class UserAccountValidator : Validator { public UserAccountValidator(NameValueCollection attributes) : base(string.Empty, "User Account") { } protected override string DefaultMessageTemplate { get { throw new NotImplementedException(); } } protected override void DoValidate(object objectToValidate, object currentTarget, string key, ValidationResults results) { if (!currentTarget.GetType().Equals(typeof(UserAccount))) { throw new Exception(); } UserAccount userAccountToValidate = (UserAccount)currentTarget; // snipped code ... this.LogValidationResult(results, "The User Account is invalid", currentTarget, key); } } Here is the XML of my ruleset in Validation.config (the NotNull rule is only there to force a failure so I could see it getting hit, and it does): <validation> <type defaultRuleset="default" assemblyName="MyProj.Entities, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="MyProj.Entities.UserAccount"> <ruleset name="default"> <properties> <property name="HashedPassword"> <validator negated="true" messageTemplate="" messageTemplateResourceName="" messageTemplateResourceType="" tag="" type="Microsoft.Practices.EnterpriseLibrary.Validation.Validators.NotNullValidator, Microsoft.Practices.EnterpriseLibrary.Validation, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Not Null Validator" /> </property> <property name="Property"> <validator messageTemplate="" messageTemplateResourceName="" messageTemplateResourceType="" tag="" type="MyProj.Entities.UserAccountValidator, MyProj.Entities, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="Custom Validator" /> </property> </properties> </ruleset> </type> </validation> And here is the stripped down version of the way I invoke the validation: var type = entity.GetType() var validator = ValidationFactory.CreateValidator(type, "default", new FileConfigurationSource("Validation.config")) var results = validator.Validate(entity) Any advice would be much appreciated! Thanks, Chris

    Read the article

  • How to map a property with formula in NHibernate?

    - by yapiskan
    I have a class which I want to add a property with using formula attribute. Here is the mapping that I use in mapping file. <property name="CurrentUserVote" type="Climate.Domain.Vote, Climate.Domain" formula="(select v from Vote v where v.AchievementId=Id and (v.IP=:CurrentUserVoteFilter.CurrentUserIP))"></property> As you see, I want this property to be an object which refers to class that already has an nhibernate mapping. Is it possible to map a property with formula attribute to a class? Thanks in advance.

    Read the article

  • NHibernate - Oracle 11g Configuration for XmlType

    - by Daffi
    Im trying to get NHibernate to work with Oracle 11g´s XmlType. The following Exception is thrown: Dialect does not support DbType.Xml My configuration looks like: <?xml version="1.0" encoding="utf-8" ?> <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> <session-factory> <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property> <property name="dialect">NHibernate.Dialect.Oracle10gDialect</property> <property name="connection.driver_class">NHibernate.Driver.OracleClientDriver</property> <property name="connection.connection_string">...</property> <property name="show_sql">false</property> </session-factory> </hibernate-configuration> Sure, the XmlType functionality was introduced in 11g but I dont know the configuration Mapping. Anyone here using this feature and willing to show its config? Thanks.

    Read the article

  • Entity Framework vs. nHibernate for Performance, Learning Curve overall features

    - by hadi
    I know this has been asked several times and I have read all the posts as well but they all are very old. And considering there have been advancements in versions and releases, I am hoping there might be fresh views. We are building a new application on ASP.NET MVC and need to finalize on an ORM tool. We have never used ORM before and have pretty much boiled down to two - nHibernate & Entity Framework. I really need some advice from someone who has used both these tools and can recommend based on experience. There are three points that I am focusing on to finalize - Performance Learning Curve Overall Capability Your advice will be highly appreciated. Best Regards,

    Read the article

  • NHibernate mapping error SQL Server 2008 Express

    - by developer
    Hi All, I tried an example from NHibernate in Action book and when I try to run the app, it throws an exception saying "Could not compile the mapping document: HelloNHibernate.Employee.hbm.xml" Below is my code, Employee.hbm.xml <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true"> <class name="HelloNHibernate.Employee, HelloNHibernate" lazy="false" table="Employee"> <id name="id" access="field"> <generator class="native"/> </id> <property name="name" access="field" column="name"/> <many-to-one access="field" name="manager" column="manager" cascade="all"/> </class> Program.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using NHibernate; using System.Reflection; using NHibernate.Cfg; namespace HelloNHibernate { class Program { static void Main(string[] args) { CreateEmployeeAndSaveToDatabase(); UpdateTobinAndAssignPierreHenriAsManager(); LoadEmployeesFromDatabase(); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); } static void CreateEmployeeAndSaveToDatabase() { Employee tobin = new Employee(); tobin.name = "Tobin Harris"; using (ISession session = OpenSession()) { using (ITransaction transaction = session.BeginTransaction()) { session.Save(tobin); transaction.Commit(); } Console.WriteLine("Saved Tobin to the database"); } } static ISession OpenSession() { if (factory == null) { Configuration c = new Configuration(); c.AddAssembly(Assembly.GetCallingAssembly()); factory = c.BuildSessionFactory(); } return factory.OpenSession(); } static void LoadEmployeesFromDatabase() { using (ISession session = OpenSession()) { IQuery query = session.CreateQuery("from Employee as emp order by emp.name asc"); IList<Employee> foundEmployees = query.List<Employee>(); Console.WriteLine("\n{0} employees found:", foundEmployees.Count); foreach (Employee employee in foundEmployees) Console.WriteLine(employee.SayHello()); } } static void UpdateTobinAndAssignPierreHenriAsManager() { using (ISession session = OpenSession()) { using (ITransaction transaction = session.BeginTransaction()) { IQuery q = session.CreateQuery("from Employee where name='Tobin Harris'"); Employee tobin = q.List<Employee>()[0]; tobin.name = "Tobin David Harris"; Employee pierreHenri = new Employee(); pierreHenri.name = "Pierre Henri Kuate"; tobin.manager = pierreHenri; transaction.Commit(); Console.WriteLine("Updated Tobin and added Pierre Henri"); } } } static ISessionFactory factory; } } Employee.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace HelloNHibernate { class Employee { public int id; public string name; public Employee manager; public string SayHello() { return string.Format("'Hello World!', said {0}.", name); } } } App.config <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler,NHibernate"/> </configSections> <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> <session-factory> <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property> <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property> <property name="connection.connection_string"> Data Source=SQLEXPRESS2008;Integrated Security=True; User ID=SQL2008;Password=;initial catalog=HelloNHibernate </property> <property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property> <property name="show_sql">false</property> </session-factory> </hibernate-configuration> </configuration>

    Read the article

  • Using Fluent NHibernate in commercial application

    - by Paja
    I want to use Fluent NHibernate in commercial desktop application, and I'm little concerned about the licensing. I've downloaded Fluent NHibernate precompiled binaries, and it contains this list of files: Antlr3.Runtime.dll Castle.Core.dll Castle.DynamicProxy2.dll FluentNHibernate.dll Iesi.Collections.dll log4net.dll NHibernate.dll NHibernate.ByteCode.Castle.dll I guess I will have to add all of these files to my Inno Setup script, which will install them on user's computer. But what should I do to comply to all of the licenses associated with each file? I'm sure I'm not the first who wants to use Fluent NHibernate in commercial application, so I hope I won't have to study each of the licenses. I'm not a lawyer.

    Read the article

  • SQL Injection with Plain-Vanilla NHibernate

    - by James D
    Hello, Plain-vanilla NHibernate setup, eg, no fluent NHibernate, no HQL, nothing except domain objects and NHibernate mapping files. I load objects via: _lightSabers = session.CreateCriteria(typeof(LightSaber)).List<LightSaber>(); I apply raw user input directly to one property on the "LightSaber" class: myLightSaber.NameTag = "Raw malicious text from user"; I then save the LightSaber: session.SaveOrUpdate(myLightSaber); Everything I've seen says that yes, under this situation you are immune to SQL injection, because of the way NHibernate parameterizes and escapes the queries under the hood. However, I'm also a relative NHibernate beginner so I wanted to double-check. *waves hand* these aren't the droids you're looking for. Thanks!

    Read the article

  • Can Fluent nhibernate's automapper be configured to handle private readonly backing fields?

    - by Mark Rogers
    I like private readonly backing fields because some objects are mostly read-only after creation, and for collections, which rarely need to be set wholesale (instead using collection methods to modify the collection). For example: public class BuildingType : DomainEntity { /* rest of class */ public IEnumerable<ActionType> ActionsGranted { get { return _actionsGranted; } } private readonly IList<ActionType> _actionsGranted = new List<ActionType>(); private readonly Image _buildingTile; public virtual Image BuildingTile { get { return _buildingTile; } } } But as far as I remember fluent-nhibernate's automapper never had a solution for private readonly backing fields, I'm wondering if that's changed in the last few months. So here's my question: How do I configure automapper or create an automapping convention to map private readonly backing fields?

    Read the article

  • Nhibernate.Bytecode.Castle Trust Level on IIS

    - by jack london
    Trying to deploy the wcf service, depended on nhibernate. And getting the following exception On Reflection activator. [SecurityException: That assembly does not allow partially trusted callers.] System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed) +150 System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck) +0 System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache) +86 System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache) +230 System.Activator.CreateInstance(Type type, Boolean nonPublic) +67 NHibernate.Bytecode.ActivatorObjectsFactory.CreateInstance(Type type) +8 NHibernate.Driver.ReflectionBasedDriver.CreateConnection() +28 NHibernate.Connection.DriverConnectionProvider.GetConnection() +56 NHibernate.Tool.hbm2ddl.SchemaExport.Execute(Action`1 scriptAction, Boolean export, Boolean justDrop) +376 in IIS configuration service's trust level is Full-trust also application's web config's trust level is full. how could i make this service in working state?

    Read the article

  • Getting Started with Fluent NHibernate

    - by Andy
    I'm trying to get into using Fluent NHibernate, and I have a couple questions. I'm finding the documentation to be lacking. I understand that Fluent NHibernate / NHibernate allows you to auto-generate a database schema. Do people usually only do this for Test/Dev databases? Or is that OK to do for a production database? If it's ok for production, how do you make sure that you're not blowing away production data every time you run your app? Once the database schema is already created, and you have production data, when new tables/columns/etc. need to be added to the Test and/or Production database, do people allow NHibernate to do this, or should this be done manually? Is there any REALLY GOOD documentation on Fluent NHibernate? (Please don't point me to the wiki because in following along with the "Your first project" code building it myself, I was getting run-time errors because they forget to tell you to add a reference. Not cool.) Thanks, Andy

    Read the article

  • How do I add multiple joins (Fetches) to a joined table using nhibernate and LINQ ?

    - by ooo
    i have these tables /entities VacationRequestDate table which has a VacationRequestId field that links with VacationRequest table VacationRequest has PersonId and RequestStatusId fields that links with Person and RequestStatus respectively. i have this query so far: IEnumerable<VacationRequestDate> dates = Session.Query<VacationRequestDate>().Fetch(r => r.VacationRequest).ThenFetch(p=>p.RequestStatus).ToList(); this works fine and joins with VacationRequest and then VacationRequest joins with RequestStatus but i can't figure out how to add an additional EAGER join to the VacationRequest table. If i add a Fetch at the end, it refers to the VacationRequestDate table If i add a ThenFetch at the end, it refers to the RequestStatus table I can't find any api that will refer to the VacationRequest table as the reference point. how would you add multiple joins to a joined table using nhibernate LINQ ?

    Read the article

  • How to look up an NHibernate entity's table mapping from the type of the entity?

    - by snicker
    Once I've mapped my domain in NHibernate, how can I reverse lookup those mappings somewhere else in my code? Example: The entity Pony is mapped to a table named "AAZF1203" for some reason. (Stupid legacy database table names!) I want to find out that table name from the NH mappings using only the typeof(Pony) because I have to write a query elsewhere. How can I make the following test pass? private const string LegacyPonyTableName = "AAZF1203"; [Test] public void MakeSureThatThePonyEntityIsMappedToCorrectTable() { string ponyTable = GetNHibernateTableMappingFor(typeof(Pony)); Assert.AreEqual(LegacyPonyTableName, ponyTable); } In other words, what does the GetNHibernateTableMappingFor(Type t) need to look like?

    Read the article

  • Free E-book on NHibernate from Syncfusion

    - by TATWORTH
    Originally posted on: http://geekswithblogs.net/TATWORTH/archive/2014/08/07/free-e-book-on-nhibernate-from-syncfusion.aspxSyncfusion are providing a free E-Book on NHibernate at http://www.syncfusion.com/resources/techportal/ebooks/nhibernate?utm_medium=edm “Master the intricacies of NHibernate, an established and powerful Object/Relational Mapper (ORM) in NHibernate Succinctly. Let author Ricardo Peres guide you toward a fuller understanding of one of the oldest and most flexible ORMs available”

    Read the article

  • MVC2 Inline XHTML Validator?

    - by GedByrne
    I am attempting to setup http://www.thejoyofcode.com/Validator_Module.aspx on a local MVC2 project. I have followed all of the steps listed in the setup guide but I cannot get the validator to kick in. If I create a bog standard .htm file or a webform with .aspx extension, I can get it to work. Anyone had any joy with this?

    Read the article

  • Where is my validator?

    - by Danny Chen
    I have a validator in my page: <asp:RequiredFieldValidator ID="rfv1" runat="server" ControlToValidate="IdentifySEDSED1TxtDate" ErrorMessage="Significant Event Date 1 is missing" ValidType="SEDate">*</asp:RequiredFieldValidator> I found that in Page_Load: (below is a screen shot from the Watch Window) this.FindControl("rfv1") {Text = "*"} rfv1 The name 'rfv1' does not exist in the current context See, I can get this control with FindControl, but I can't get it using ID directly! What happens?

    Read the article

  • Cross field validation with Hibernate Validator (3.1.0.GA)

    - by Joshua
    How do we enforce cross field validation with hibernate validator 3.1.0.GA create table user (id, start_date, end_date, ...) e.g. college graduation finishing date for a student should be greater than the graduation start date How do we enforce this, so that the validation messages can be shown in the UI on save / update operations. The UI is built using JSF, Richfaces

    Read the article

  • jQuery Validator's "required" not working when value is set at statup

    - by nandrew
    Hello, I have a problem with jQuery Validator. I want to use "required" property on a text input. It doesn't work when input has set value attribute by HTML code (tested on Firefox (3.5), and on IE 8 - on IE it works a bit better). Story: 1. Page loads; 2. value is cleared; 3. focus is changed. 4. Nothing happens but the error message should be displayed; 5. getting back to the field and typing some characters. 6. changing focus; 7. getting back to the field; 8. clearing the field. 9. Error is displayed even before leaving the field. The HTML code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <script src="Web/Scripts/jquery-1.3.2.min.js" type="text/javascript"></script> <script src="Web/Scripts/jquery.validate.js" type="text/javascript"></script> </head> <body> <form id="form1"> <input type="text" id="name1" name="name1" value="test" /><br /> <input type="text" /> </form> <script type="text/javascript"> $(document).ready(function() { var validator = $("form").validate({ rules: { name1: { required: true, minlength: 2 } }, messages: { name1: "bad name" }, }); }); </script> </body> </html>

    Read the article

< Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >