Search Results

Search found 14 results on 1 pages for 'chev'.

Page 1/1 | 1 

  • nhibernate mapping: A collection with cascade="all-delete-orphan" was no longer referenced

    - by Chev
    Hi All I am having some probs with my fluent mappings. I have an entity with a child collection of entities i.e Event and EventItems for example. If I set my cascade mapping of the collection to AllDeleteOrphan I get the following error when saving a new entity to the DB: NHibernate.HibernateException : A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance: Core.Event.EventItems If I set the cascade to All it works fine? Below are my classes and mapping files: public class EventMap : ClassMap<Event> { public EventMap() { Id(x => x.Id, "Id") .UnsavedValue("00000000-0000-0000-0000-000000000000") .GeneratedBy.GuidComb(); Map(x => x.Name); HasMany(x => x.EventItems) .Inverse() .KeyColumn("EventId") .AsBag() .Cascade.AllDeleteOrphan(); } } public class EventItemMap : SubclassMap<EventItem> { public EventItemMap() { Id(x => x.Id, "Id") .UnsavedValue("00000000-0000-0000-0000-000000000000") .GeneratedBy.GuidComb(); References(x => x.Event, "EventId"); } } public class Event : EntityBase { private IList<EventItem> _EventItems; protected Event() { InitMembers(); } public Event(string name) : this() { Name = name; } private void InitMembers() { _EventItems = new List<EventItem>(); } public virtual EventItem CreateEventItem(string name) { EventItem eventItem = new EventItem(this, name); _EventItems.Add(eventItem); return eventItem; } public virtual string Name { get; private set; } public virtual IList<EventItem> EventItems { get { return _EventItems.ToList<EventItem>().AsReadOnly(); } protected set { _EventItems = value; } } } public class EventItem : EntityBase { protected EventItem() { } public EventItem(Event @event, string name):base(name) { Event = @event; } public virtual Event Event { get; private set; } } Pretty stumped here. Any tips greatly appreciated. Chev

    Read the article

  • Deleting unreferenced child records with nhibernate

    - by Chev
    Hi There I am working on a mvc app using nhibernate as the orm (ncommon framework) I have parent/child entities: Product, Vendor & ProductVendors and a one to many relationship between them with Product having a ProductVendors collection Product.ProductVendors. I currently am retrieving a Product object and eager loading the children and sending these down the wire to my asp.net mvc client. A user will then modify the list of Vendors and post the updated Product back. I am using a custom model binder to generate the modified Product entity. I am able to update the Product fine and insert new ProductVendors. My problem is that dereferenced ProductVendors are not cascade deleted when specifying Product.ProductVendors.Clear() and calling _productRepository.Save(product). The problem seems to be with attaching the detached instance. Here are my mapping files: Product <?xml version="1.0" encoding="utf-8" ?> <id name="Id"> <generator class="guid.comb" /> </id> <version name="LastModified" unsaved-value="0" column="LastModified" /> <property name="Name" type="String" length="250" /> ProductVendors <?xml version="1.0" encoding="utf-8" ?> <id name="Id"> <generator class="guid.comb" /> </id> <version name="LastModified" unsaved-value="0" column="LastModified" /> <property name="Price" /> <many-to-one name="Product" class="Product" column="ProductId" lazy="false" not-null="true" /> <many-to-one name="Vendor" class="Vendor" column="VendorId" lazy="false" not-null="true" /> Custom Model Binder: using System; using Test.Web.Mvc; using Test.Domain; namespace Spoked.MVC { public class ProductUpdateModelBinder : DefaultModelBinder { private readonly ProductSystem ProductSystem; public ProductUpdateModelBinder(ProductSystem productSystem) { ProductSystem = productSystem; } protected override void OnModelUpdated(ControllerContext controllerContext, ModelBindingContext bindingContext) { var product = bindingContext.Model as Product; if (product != null) { product.Category = ProductSystem.GetCategory(new Guid(bindingContext.ValueProvider["Category"].AttemptedValue)); product.Brand = ProductSystem.GetBrand(new Guid(bindingContext.ValueProvider["Brand"].AttemptedValue)); product.ProductVendors.Clear(); if (bindingContext.ValueProvider["ProductVendors"] != null) { string[] productVendorIds = bindingContext.ValueProvider["ProductVendors"].AttemptedValue.Split(','); foreach (string id in productVendorIds) { product.AddProductVendor(ProductSystem.GetVendor(new Guid(id)), 90m); } } } } } } Controller: [AcceptVerbs(HttpVerbs.Post)] public ActionResult Update(Product product) { using (var scope = new UnitOfWorkScope()) { //product.ProductVendors.Clear(); _productRepository.Save(product); scope.Commit(); } using (new UnitOfWorkScope()) { IList<Vendor> availableVendors = _productSystem.GetAvailableVendors(product); productDetailEditViewModel = new ProductDetailEditViewModel(product, _categoryRepository.Select(x => x).ToList(), _brandRepository.Select(x => x).ToList(), availableVendors); } return RedirectToAction("Edit", "Products", new {id = product.Id.ToString()}); } The following test does pass though: [Test] [NUnit.Framework.Category("ProductTests")] public void Can_Delete_Product_Vendors_By_Dereferencing() { Product product; using(UnitOfWorkScope scope = new UnitOfWorkScope()) { Console.Out.WriteLine("Selecting..."); product = _productRepository.First(); Console.Out.WriteLine("Adding Product Vendor..."); product.AddProductVendor(_vendorRepository.First(), 0m); scope.Commit(); } Console.Out.WriteLine("About to delete Product Vendors..."); using (UnitOfWorkScope scope = new UnitOfWorkScope()) { Console.Out.WriteLine("Clearing Product Vendor..."); _productRepository.Save(product); // seems to be needed to attach entity to the persistance manager product.ProductVendors.Clear(); scope.Commit(); } } Going nuts here as I almost have a very nice solution between mvc, custom model binders and nhibernate. Just not seeing my deletes cascaded. Any help greatly appreciated. Chev

    Read the article

  • Help setting up a dns nameserver for parking domains

    - by Chev
    Hi There I need to be able to create name server entries for new domains being registered and need some help in setting up a name server on the internet. I am looking for some good resources - prefereably with a windows machine. Any tips to help getting started greatly appreciated. Cheers.

    Read the article

  • asp.net mvc 1.0 - how to render a partial view as a string

    - by Chev
    Hi There I need to render a partial view to a string within a controller action. I have the following sample code, but the ControllerContext.ParentActionViewContext does not seem to exist in mvc 1.0 // Get the IView of the PartialView object. var view = PartialView("MyPartialView").View; // Initialize a StringWriter for rendering the output. var writer = new StringWriter(); // Do the actual rendering. view.Render(ControllerContext.ParentActionViewContext, writer); Any tips greatly appreciated.

    Read the article

  • Can a View be returned as a JSON object in ASP.Net MVC

    - by Chev
    I want to know if it is possibe to return a view as a JSON object. In my controller I want to do something like the following: [AcceptVerbs("Post")] public JsonResult SomeActionMethod() { return new JsonResult { Data = new { success = true, view = PartialView("MyPartialView") } }; } In html: $.post($(this).attr('action'), $(this).serialize(), function(Data) { alert(Data.success); $("#test").replaceWith(Data.view); }); Any feedback greatly appreciated.

    Read the article

  • nhibernate cascade - problem with detached entities

    - by Chev
    I am going nuts here trying to resolve a cascading update/delete issue :-) I have a Parent Entity with a collection Child Entities. If I modify the list of Child entities in a detached Parent object, adding, deleting etc - I am not seeing the updates cascaded correctly to the Child collection. Mapping Files: <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Domain" namespace="Domain"> <class name="Parent" table="Parent" > <id name="Id"> <generator class="guid.comb" /> </id> <version name="LastModified" unsaved-value="0" column="LastModified" /> <property name="Name" type="String" length="250" /> <bag name="ParentChildren" lazy="false" table="Parent_Children" cascade="all-delete-orphan" inverse="true"> <key column="ParentId" on-delete="cascade" /> <one-to-many class="ParentChildren" /> </bag> </class> <class name="ParentChildren" table="Parent_Children"> <id name="Id"> <generator class="guid.comb" /> </id> <version name="LastModified" unsaved-value="0" column="LastModified" /> <many-to-one name="Parent" class="Parent" column="ParentId" lazy="false" not-null="true" /> </class> </hibernate-mapping> Test [Test] public void Test() { Guid id; int lastModified; // add a child into 1st session then detach using(ISession session = Store.Local.Get<ISessionFactory>("SessionFactory").OpenSession()) { Console.Out.WriteLine("Selecting..."); Parent parent = (Parent) session.Get(typeof (Parent), new Guid("4bef7acb-bdae-4dd0-ba1e-9c7500f29d47")); id = parent.Id; lastModified = parent.LastModified + 1; // ensure the detached version used later is equal to the persisted version Console.Out.WriteLine("Adding Child..."); Child child = (from c in session.Linq<Child>() select c).First(); parent.AddChild(child, 0m); session.Flush(); session.Dispose(); // not needed i know } // attach a parent, then save with no Children using (ISession session = Store.Local.Get<ISessionFactory>("SessionFactory").OpenSession()) { Parent parent = new Parent("Test"); parent.Id = id; parent.LastModified = lastModified; session.Update(parent); session.Flush(); } } I assume that the fact that the product has been updated to have no children in its collection - the children would be deleted in the Parent_Child table. The problems seems to be something to do with attaching the Product to the new session? As the cascade is set to all-delete-orphan I assume that changes to the collection would be propagated to the relevant entities/tables? In this case deletes? What am I missing here? C

    Read the article

  • Problem with asp.net mvc route not firing when in <script> tag

    - by Chev
    I cannot get the following route to fire when a url is requested from a script tag. I have the following route: // maps to "/cache/cachecontent/JavaScriptInclude/1/javascript" routes.MapRoute( null, "cache/{action}/{key}/{version}/{type}", new { controller = "Cache", action = "CacheContent", key = "", version = "", type = "" } ); I have a javascript script tag like: <script type="text/javascript" src="/cache/cachecontent/JavaScriptInclude/1/javascript" /> Yet the route is not firing and the controller is not instantiated. If i drop the url into the address bar of the browser all is fine, but is not triggered from the javascript tag? Any ideas?

    Read the article

  • Actionscript - Adding EventListener to multiple buttons on stage

    - by Chev
    I have a little problem with adding EventListener to multiple objects on stage. I have above 40 buttons on stage named "Button01","Button02" .. "Button40", and i'm looking for easiest way to add EventListener to all of them. Creating something like Button01.addEventListener(MouseEvent.CLICK, doSomething) Button02.addEventListener(MouseEvent.CLICK, doSomething) .. Button40.addEventListener(MouseEvent.Click, doSomething) (Notice the same function). isn't solution i'm looking for :(. Thanks in advice.

    Read the article

  • create parent child array from inline data in php

    - by abhie
    actually i have simple problem but i forget how to solve it.. :D i have data on table with following format 01 Johson 01 Craig 01 Johson 02 Daniel 01 Johson 03 Abbey 02 Dawson 01 Brown 02 Dawson 02 Agust 03 Brick 01 Chev 03 Brick 01 Flinch so i want it to become an array like this 01 Johson => 01 Craig ``````````````02 Daniel ```````````````03 Abey ` etc... how to iterate trough the data and make it array like that... i'm newby in PHP :))

    Read the article

  • Help writing server script to ban IP's from a list

    - by Chev_603
    I have a VPS that I use as an openvpn and web server. For some reason, my apache log files are filled with thousands of these hack attempts: "POST /xmlrpc.php HTTP/1.0" 404 395 These attack attempts fill up 90% of my logs. I think it's a WordPress vulnerability they're looking for. Obviously they are not successful (I don't even have Wordpress on my server), but it's annoying and probably resource consuming as well. I am trying to write a bash script that will do the following: Search the apache logs and grab the offending IP's (even if they try it once), Sort them into a list with each unique IP on a seperate line, And then block them using the IP table rules. I am a bash newb, and so far my script does everything except Step 3. I can manually block the IP's, but that's tedious and besides, this is Linux and it's perfectly capable of doing it for me. I also want the script to be customizable so that I (or anyone else who wants to use it) can change the variables to suit whatever situation I/they may deal with in the future. Here is the script so far: #!/bin/bash ##IP LIST GENERATOR ##Author Chev Young ##Script to search Apache logs and list IP's based on custom filters ## ##Define our variables: DIRECT=~/Script ##Location of script&where to put results/temp files LOGFILE=/var/log/apache2/access.log ## Logfile to search for offenders TEMPLIST=xml_temp ## Temporary file name IP_LIST=ipstoban ## Name of results file FILTER1=xmlrpc ## What are we looking for? (Requests we want to ban) cd $DIRECT if [ ! -f $TEMPLIST ];then touch $TEMPLIST ##Create temp file fi cat $LOGFILE | grep $FILTER1 >> $DIRECT/$TEMPLIST ## Only interested in the IP's, so: sed -e 's/\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\).*$/\1/' -e t -e d $DIRECT/$TEMPLIST | sort | uniq > $DIRECT/$IP_LIST rm $TEMPLIST ## Clean temp file echo "Done. Results located at $DIRECT/$IP_LIST" So I need help with the next part of the script, which should ban the IP's (incoming and perhaps outgoing too) from the resulting $IP_LIST file. I don't care if it utilizes UFW or IPTables directly, as long as it bans the IP's. I'd probably run it as a cron task. What I'm having trouble with is understanding how to use line of the result file as a seperate variable to do something like: ufw deny $IP1 $IP2 $IP3, ect Any ideas? Thanks.

    Read the article

1