Search Results

Search found 8688 results on 348 pages for 'per salmi'.

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

  • Checkstyle: cannot summarise issues per author ?

    - by David Michel
    Hi all, I'm trying to use checkstyle for a java project but I can't seem to get it working properly: While it apparently runs smoothly, the html report doesn't give any info per authors as it should, i.e. the authors table is empty. The thing is I don't know how checkstyle identify an author. Does it look at the java doc tag @author ? at the class level or at the method level ? The ant task I used is below: <taskdef resource="checkstyletask.properties" classpath="${libs.dir}/checkstyle-all-5.0.jar"/> <target name="checkstyle" description="Generates a report of code convention violations."> <mkdir dir="${checkstyle.dir}"/> <checkstyle config="${util.dir}/checkstyle/sun_checks.xml" failureProperty="checkstyle.failure" failOnViolation="false"> <formatter type="xml" tofile="${checkstyle.dir}/checkstyle_report.xml"/> <fileset dir="${src.dir}" includes="**/*.java"/> </checkstyle> <xslt in="${checkstyle.dir}/checkstyle_report.xml" out="${checkstyle.dir}/checkstyle_report.html" style="${util.dir}/checkstyle/checkstyle-author.xsl"/> </target> Many thanks for your help David

    Read the article

  • NHibernate Session per Call in WCF - How to Rollback

    - by Corey Coogan
    I've implemented some components to use WCF with both an IoC Container (StructureMap) and the Session per Call pattern. The NHibernate stuff is most taken from here: http://realfiction.net/Content/Entry/133. It seems to be OK, but I want to open a transaction with each call and commit at the end, rather than just Flush() which how its being done in the article. Here's where I am running into some problems and could use some advice. I haven't figured out a good way to rollback. I realize I can check the CommunicationState and if there's an exception, rollback, like so: public void Detach(InstanceContext owner) { if (Session != null) { try { if(owner.State == CommunicationState.Faulted) RollbackTransaction(); else CommitTransaction(); } finally { Session.Dispose(); } } } void CommitTransaction() { if(Session.Transaction != null && Session.Transaction.IsActive) Session.Transaction.Commit(); } void RollbackTransaction() { if (Session.Transaction != null && Session.Transaction.IsActive) Session.Transaction.Rollback(); } However, I almost never return a faulted state from a service call. I would typically handle the exception and return an appropriate indicator on my response object and rollback the transaction myself. The only way I can think of handling this would be to inject not only repositories into my WCF services, but also an ISession so I can rollback and handle the way I want. That doesn't sit well with me and seems kind of leaky. Anyone else handling the same problem?

    Read the article

  • NHibernate: how to handle entity-based validation using session-per-request pattern, without control

    - by Seth Petry-Johnson
    What is the best way to do entity-based validation (each entity class has an IsValid() method that validates its internal members) in ASP.NET MVC, with a "session-per-request" model, where the controller has zero (or limited) knowledge of the ISession? Here's the pattern I'm using: Get an entity by ID, using an IFooRepository that wraps the current NH session. This returns a connected entity instance. Load the entity with potentially invalid data, coming from the form post. Validate the entity by callings its IsValid() method. If valid, call IFooRepository.Save(entity). Otherwise, display error message. The session is currently opened when the request begins and flushed when the request ends. Since my entity is connected to a session, flushing the session attempts to save the changes even if the object is invalid. What's the best way to keep validation logic in the entity class, limit controller knowledge of NH, and avoid saving invalid changes at the end of a request? Option 1: Explicitly evict on validation failure, implicitly flush: if the validation fails, I could manually evict the invalid object in the action method. If successful, I do nothing and the session is automatically flushed. Con: error prone and counter-intuitive ("I didn't call .Save(), why are my invalid changes being saved anyways?") Option 2: Explicitly flush, do nothing by default: By default I can dispose of the session on request end, only flushing if the controller indicates success. I'd probably create a SaveChanges() method in my base controller that sets a flag indicating success, and then query this flag when closing the session at request end. Pro: More intuitive to troubleshoot if dev forgets this step [relative to option 1] Con: I have to call IRepository.Save(entity)' and SaveChanges(). Option 3: Always work with disconnected objects: I could modify my repositories to return disconnected/transient objects, and modify the Repo.Save() method to re-attach them. Pro: Most intuitive, given that controllers don't know about NH. Con: Does this defeat many of the benefits I'd get from NH?

    Read the article

  • svn+apache per directory access control: weird permissions issue (403 Forbidden error)

    - by gveda
    Hi, I had a perfectly working svn+apache install where I was using per directory access control to restrict access to various parts of the repository. In particular, no one had access to the top level in the repository [/]. People had access to folders like [/www] etc. I was specifying these permissions in a file (svn-access-file). I had to move to a new machine. So I installed subversion-1.6.3 and httpd-2.2.11 on it, and modified the conf file to mimic the conf file on the old machine (and I copied the svn-access-file and the svn-auth-file). Then I took an svn dump and did a load to put stuff back in the new repository. Now I can check stuff out, modify stuff, and commit. However, as soon as I try to do an 'svn up' on an already checked out copy of some sub-folder [/www/people], I get the following error: svn: Server sent unexpected return value (403 Forbidden) in response to OPTIONS request for 'https://[servername]/svn' It seems the problem is that it is trying to access the top level directory [/] even though really it should only be trying to access [/www]. If I temporarily give the user access to [/], it works. Can someone please tell me how to fix this? Everything worked on the old machine. Thanks! Gaurav

    Read the article

  • Scalable Full Text Search With Per User Result Ordering

    - by jeremy
    What options exist for creating a scalable, full text search with results that need to be sorted on a per user basis? This is for PHP/MySQL (Symfony/Doctrine as well, if relevant). In our case, we have a database of workouts that have been performed by users. The workouts that the user has done before should appear at the top of the results. The more frequently they've done the workout, the higher it should appear in search matches. If it helps, you can assume we know the number of times a user has done a workout in advance. Possible Solutions Sphinx - Use Sphinx to implement full text search, do all the querying and sorting in MySQL. This seems promising (and there's a Symfony Plugin!) but I don't know much about it. Lucene - Use Lucene to perform full text search and put the users' completions into the query. As is suggested in this Stack Overflow thread. Alternatively, use Lucene to retrieve the results, then reorder them in PHP. However, both solutions seem clunky and potentially unscalable as a user may have completed hundreds of workouts. Mysql - No native full text support (InnoDB), so we'd have use LIKE or REGEX, which isn't scalable.

    Read the article

  • StructureMap Configuration Per Thread/Request for the Full Dependency Chain

    - by Phil Sandler
    I've been using Structuremap for a few months now, and it has worked great on some smaller (green field) projects. Most of the configurations I have had to set up involve a single implementation per interface. In the cases where I needed to choose a specific implementation at runtime, I created a factory class that used ObjectFactory.GetNamedInstance<(). In the smaller projects, there were few enough of these cases where I was comfortable with the references to ObjectFactory. My understanding is that you want to limit these references as much as possible, and ideally only reference the ObjectFactory once. I am working to refactor a larger codebase to use IOC/StructureMap, and am finding that I may need many of these factory classes with ObjectFactory references to get what I need. Essentially, I am creating a "root service" with the ObjectFactory, so that everything in the dependency chain is managed by the container. The root service is created by name (i.e. "BuildCar", "BuildTruck"), and the services needed deeper in the dependency chain could also be constructed using the same name--so the "IAttachWheels" service could vary based on whether a car or truck is being built. Since the class that depends on IAttachWheels is the same in both configurations, I don't think I can use ConstructedBy in the registry to choose the implementation. Also, to be clear, the IAttachWheels implementations need to be managed by the container as well, because the dependency chain runs fairly deep. I looked briefly at Profiles as an option, but read (here on StackOverflow) that changing profiles essentially changes implementations for all threads. Is there a feature that is similar to profiles that is thread/request specific? Is the factory class that references ObjectFactory approach the right way to go? Any thoughts would be appreciated.

    Read the article

  • RequestBuilder timeouts and browser connection limits per domain.

    - by WesleyJohnson
    This is specifically about GWT's RequestBuilder, but should apply to general XHR as well. My company is having me build a near realtime chat application over HTTP. Yes, I do realize there are better ways to do chat aplications, but this is what they want. Eventually we want it working on the iPad/iPhone as well so flash is out, which rules out websockets and comet as well, I think? Anyway, I'm running into issues were I've set GWT's RequestBuilder timeout to 10 seconds and we get very random and sporadic timeouts. We've got error handling and emailing on the server side and never get any errors, which suggests the underlying XHR request that RequestBuilder is built on, never gets to the server and times out after 10 seconds. We're using these request to poll the server for new messages rather often and also for sending new messages to the server and also polling (less frequently) for other parts of application. What I'm afraid of is that we're running into the browsers limit on concurrent connections to the same domain (2 for IE by default?). Now my question is - If I construct a RequestBuilder and call it's send() method and the browser blocks it from sending until one of the 2 connections per domain is free, does the timeout still start while the request is being blocked or will it not start until the browser actually releases the underlying XHR? I hope that's clear, if not please let me know and I'll try to explain more.

    Read the article

  • Counting a cell up per Objects

    - by Auro
    hey i got a problem once again :D a little info first: im trying to copy data from one table to an other table(structure is the same). now one cell needs to be incremented, beginns per group at 1 (just like a histroy). i have this table: create table My_Test/My_Test2 ( my_Id Number(8,0), my_Num Number(6,0), my_Data Varchar2(100)); (my_Id, my_Num is a nested PK) if i want to insert a new row, i need to check if the value in my_id already exists. if this is true then i need to use the next my_Num for this Id. i have this in my Table: My_Id My_Num My_Data 1 1 'test1' 1 2 'test2' 2 1 'test3' if i add now a row for my_Id 1, the row would look like this: i have this in my Table: My_Id My_Num My_Data 1 3 'test4' this sounds pretty easy ,now i need to make it in a SQL and on SQL Server i had the same problem and i used this: Insert Into My_Test (My_Id,My_Num,My_Data) SELECT my_Id, ( SELECT CASE ( CASE MAX(a.my_Num) WHEN NULL THEN 0 Else Max(A.My_Num) END) + b.My_Num WHEN NULL THEN 1 ELSE ( CASE MAX(a.My_Num) WHEN NULL THEN 0 Else Max(A.My_Num) END) + b.My_Num END From My_Test A where my_id = 1 ) ,My_Data From My_Test2 B where my_id = 1; this Select gives null back if no Rows are found in the subselect is there a way so i could use max in the case? and if it give null back it should use 0 or 1? greets Auro

    Read the article

  • How to determine the amount to spend per phrase on Adwords research?

    - by Anonymous -
    My company would like to start a PPC advertising campaign. Whilst I understand the concept and how to set everything up from a technical point of view, this is something I've never done before. Logically, we'd like to test out a wide range of keywords that we think would lead to conversions, which we've put together through brainstorming and with some help from Google's External Keyword Tool. Sub-question whilst I remember - am I correct in thinking that in Google's keyword tool, keywords that we think will perform well that have a low competition yet high monthly searches are good since there will be less advertisers, meaning our bid per click will be less? Is there a common benchmark or process of doing a round of tests with keywords? Should we wait for 100 clicks on each keyword, see which ones have lead to the most sales (or rather, sales that are sustainable with the cost per click of that keyword), then drop the ones which aren't converting and put that budget onto the converting keywords? We realistically have a few hundred keywords/phrases we would like to test, but spending $100 per keyword/phrase is going to work out as quite an expensive test. It would be nice to be able to spend $5-10 per phrase, but I don't think the sample size would be great enough to determine anything usefully reliable. Another approach might be to setup all the keywords, and those that bring the most sales within x hours/days would be the ones we use. What is the common procedure with things like this? I know there are a plethora of companies that specialize in exactly this, but this is something we anticipate doing a lot in the future, so it would make sense to do it in house if at all possible.

    Read the article

  • Limit for Google calendar SMS notification per day

    - by pit777
    What is the limit for Google calendar SMS notification per day? How to detect I reached sms limit? Google write only this: http://www.google.com/support/calendar/bin/answer.py?hl=en&answer=36589 You might have reached the limit for SMS notifications. There is a limit to the number of SMS notifications you can receive each day. This limit shouldn't affect most users, but it's something to keep in mind if you've scheduled a large number of events and are no longer receiving SMS notifications. I created sms reminder based on google calendar api(apps-script), but I think now I reached the daily limit for SMS notifications... but google not informed what is exactly amount of sms limit restriction :/ function emailNotification() { // POWIADOMIENIA SMS O NOWEJ POCZCIE var calendarID = "[email protected]"; // id kalendarza o nazwie „sms4email” var gmailLabelTODO = "autoscriptslabels/sms"; // etykieta „AutoScriptsLabels/SMS” var gmailLabelDONE = "done/_sms"; // etykieta „DONE/_SMS” var calendarEventDescription = "this-is-sms_notification-mark"; // etykieta utworzonego zdarzenia, dzieki której mozna bedzie je znalezc podczas kasowania var calendar = CalendarApp.getCalendarById(calendarID); // otwieramy kalendarz var threads = GmailApp.getUserLabelByName(gmailLabelTODO).getThreads(); // zmienna przechowujaca kolekcje lancuszków z etykieta TODO var now = new Date(); if(threads == 0) return; // zaprzestanie wykonywania, jezeli brak nowych lancuszków for(i in threads) // tworzymy zdarzenia { var title = threads[i].getFirstMessageSubject(); // tytul emaila var startDate = new Date(now.getTime()+120000); var endDate = new Date(now.getTime()+120000); var messages = threads[i].getMessages(); var senderEmail = messages[0].getFrom(); // nadawca emaila var advancedArgs = {location:senderEmail, description:calendarEventDescription}; calendar.createEvent(title, startDate, endDate, advancedArgs); } Utilities.sleep(1000); GmailApp.getUserLabelByName(gmailLabelDONE).addToThreads(threads); // dodawanie etykiety DONE Utilities.sleep(1000); GmailApp.getUserLabelByName(gmailLabelTODO).removeFromThreads(threads); // usuwanie etykiety TODO Utilities.sleep(120000); // czekamy az kalendarz wysle SMS var TodaysEvents = calendar.getEventsForDay(now); for (i in TodaysEvents) // wyszukiwanie wedlug zdarzenia i kasowanie po wyslaniu { if (TodaysEvents[i].getDescription()==calendarEventDescription) TodaysEvents[i].deleteEvent(); } }

    Read the article

  • pagination - 10 pages per page

    - by arthur
    I have a pagination script that displays a list of all pages like so: prev [1][2][3][4][5][6][7][8][9][10][11][12][13][14] next But I would like to only show ten of the numbers at a time: prev [3][4][5][6][7][8][9][10][11][12] next How can I accomplish this? Here is my code so far: <?php /* Set current, prev and next page */ $page = (!isset($_GET['page']))? 1 : $_GET['page']; $prev = ($page - 1); $next = ($page + 1); /* Max results per page */ $max_results = 2; /* Calculate the offset */ $from = (($page * $max_results) - $max_results); /* Query the db for total results. You need to edit the sql to fit your needs */ $result = mysql_query("select title from topics"); $total_results = mysql_num_rows($result); $total_pages = ceil($total_results / $max_results); $pagination = ''; /* Create a PREV link if there is one */ if($page > 1) { $pagination .= '< a hr_ef="?page='.$prev.'">Previous</a> '; } /* Loop through the total pages */ for($i = 1; $i <= $total_pages; $i++) { if(($page) == $i) { $pagination .= $i; } else { $pagination .= '< a hr_ef="index.php?page='.$i.'">'.$i.'</a>'; } } /* Print NEXT link if there is one */ if($page < $total_pages) { $pagination .= '< a hr_ef="?page='.$next.'"> Next</a>'; } /* Now we have our pagination links in a variable($pagination) ready to print to the page. I pu it in a variable because you may want to show them at the top and bottom of the page */ /* Below is how you query the db for ONLY the results for the current page */ $result=mysql_query("select * from topics LIMIT $from, $max_results "); while ($i = mysql_fetch_array($result)) { echo $i['title'].'<br />'; } echo $pagination; ?>

    Read the article

  • How to map inheritance with property returned other inheritance?

    - by dario-g
    Hi I have abstract class Vehicle and two classes that derive from: Car and ForkLift. public abstract class Vehicle { public EngineBase Engine { get; set; } } public class Car : Vehicle { public GasEngine Engine { get; set; } } public class ForkLift : Vehicle { public ElectricEngine Engine { get; set; } } and Engine clasess: public abstract class Engine { } public class GasEngine : Engine { } public class ElectricEngine : Engine { } Engines are mapped with "table per class hierarchy". With Vehicles I want to use the same pattern. How to map Engine class and derived with that Engine property?

    Read the article

  • Is there a way to find TOP X records with grouped data?

    - by Chris Simmons
    I'm working with a Sybase 12.5 server and I have a table defined as such: CREATE TABLE SomeTable( [GroupID] [int] NOT NULL, [DateStamp] [datetime] NOT NULL, [SomeName] varchar(100), PRIMARY KEY CLUSTERED (GroupID,DateStamp) ) I want to be able to list, per [GroupID], only the latest X records by [DateStamp]. The kicker is X 1, so plain old MAX() won't cut it. I'm assuming there's a wonderfully nasty way to do this with cursors and what-not, but I'm wondering if there is a simpler way without that stuff. I know I'm missing something blatantly obvious and I'm gonna kick myself for not getting it, but .... I'm not getting it. Please help. Is there a way to find TOP X records, but with grouped data?

    Read the article

  • Building a system that allows users to see a video only once

    - by Bart van Heukelom
    My client wants to distribute a video to some people, specifically car dealers, but he doesn't want the video to end up on Youtube or something like that. Therefore he wants the recipients of the video to be able to see it only once. My idea to implement this is: Generate a unique key per viewer Send each viewer a link to a page with a Flash based video player, with their key in the URL Have Flash get the video from the server. On the server the key is checked and the file sent (using php's readfile or something equivalent). Then the key is invalidated. I was thinking this wouldn't take more than a day to build. I know that if you want somebody to be able to play something, you implicitly give them the power to record it as well, but the client just wants me to make it as hard as possible. Do you think this is secure enough for the intended audience? Anything else I can do to add some security without exceeding the development time of 1 day? I'm also interested in ready made solutions, if they exist.

    Read the article

  • Single Table Per Class Hierarchy with an abstract superclass using Hibernate Annotations

    - by Andy Hull
    I have a simple class hierarchy, similar to the following: @Entity @Table(name="animal") @Inheritance(strategy=InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name="animal_type", discriminatorType=DiscriminatorType.STRING) public abstract class Animal { } @Entity @DiscriminatorValue("cat") public class Cat extends Animal { } @Entity @DiscriminatorValue("dog") public class Dog extends Animal { } When I query "from Animal" I get this exception: "org.hibernate.InstantiationException: Cannot instantiate abstract class or interface: Animal" If I make Animal concrete, and add a dummy discriminator... such as @DiscriminatorValue("animal")... my query returns my cats and dogs as instances of Animals. I remember this being trivial with HBM based mappings but I think I'm missing something when using annotations. Can anyone help? Thanks!

    Read the article

  • NHibernate HiLo - new column per entity and HiLo catches

    - by Gareth
    Im currently using the hilo id generator for my classes but have just been using the minimal of settings eg <class name="ClassA" <id name="Id" column="id" unsaved-value="0" <generator class="hilo" / </id ... But should I really be specifying a new column for NHibernate to use foreach entity and providing it with a max lo? <class name="ClassA" <id name="Id" column="id" unsaved-value="0" <generator class="hilo" <param name="table"hibernate_unique_key</param <param name="column"classA_nexthi</param <param name="max_lo"20</param </generator </id ... <class name="ClassB" <id name="Id" column="id" unsaved-value="0" <generator class="hilo" <param name="table"hibernate_unique_key</param <param name="column"classB_nexthi</param <param name="max_lo"20</param </generator </id ... Also I've noticed that when I do the above the SchemaExport will not create all the columns - only classB_nexthi, is there something else im doing wrong. Thanks

    Read the article

  • c#Repository pattern: One repository per subclass?

    - by Alex
    I am wondering if you would create a repository for each subclass of a domain model. There are two classes for example: public class Person { public virtual String GivenName { set; get; } public virtual String FamilyName { set; get; } public virtual String EMailAdress { set; get; } } public class Customer : Person { public virtual DateTime RegistrationDate { get; set; } public virtual String Password { get; set; } } Would you create both a PersonRepository and a CustomerRepository or just the PersonRepository which would also be able to execute Customer related queries?

    Read the article

  • Ruby on Rails: having two xmlbuilder templates per action , one for errors one for regular output

    - by randombits
    What's the best way to handle having two templates (or should it be one, DRY?) for xml builder templates? I'm building a web api with Rails and wanted to see an example of how to have a view that does regular output vs one that does error output. I've been using @obj.to_xml for a while, but my requirements have changed and require me building my own error templates. do you typically have both views in one with a condition above for errors such as app/views/myresource/create.xml.builder unless @myobj.errors.empty? // xml for errors here? end // regular xml view

    Read the article

  • IText Lines Per Page?

    - by exit174
    I have used IText(Sharp) to make PDFs from raster images but have never used IText to build text based PDF's. In this new scenario, I have N words of ASCII text that I need to add as text pages to a new PDF. Each page should be 8.5 x 11, .5 margins, using some monospaced font. Is IText(Sharp) smart enough to automatically apply line and page breaks where necessary or do I need to do this manually? Are their any good IText tutorials for this scenario? thanks! scottm

    Read the article

  • 24 hours per day and freelance programming jobs

    - by Luca
    I'm working on stimulanting projects at my job. I like it. I like programming! I have accumulated several years of experience now. Sometime happens I develop other projects (even more stimulant of my main job). Some more money cannot hurts! The problem is that my free time has decreased a lot, leading me to develop until late evening. I usually program each day (I like to develop my own projects, even if only a few lines at a time). But it is one thing to plan for my pleasure, it is one thing to plan for business. So, my question is how to balance free time with these additional jobs? What experiences do you have? How much you can develop for long time (in a medium interval, say, weeks)? Every thought is welcome!

    Read the article

  • SQL query to count and list the different counties per zip code

    - by Chris
    I have a sql server 2005 table called ZipCode, which has all the US ZIPs in it. For each entry, it lists the zip, county, city, state, and several other details. Some zipcodes span multiple cities and some even span multiple counties. As a result, some zipcodes appear many times in the table. I am trying to query the table to see which zipcodes go across multiple counties. This is what I have so far: select zipcode, count(zipcode) as total, county, state from zipcode group by zipcode, county, state order by zipcode Of 19248 records in the result set, here are the first several records returned: zipcode total county state 00501 2 SUFFOLK NY 00544 2 SUFFOLK NY 00801 3 SAINT THOMAS VI 00802 3 SAINT THOMAS VI 00803 3 SAINT THOMAS VI 00804 3 SAINT THOMAS VI 00805 1 SAINT THOMAS VI 00820 2 SAINT CROIX VI 00821 1 SAINT CROIX VI 00822 1 SAINT CROIX VI 00823 2 SAINT CROIX VI 00824 2 SAINT CROIX VI In this particular example, each zip with a total of two or more happens to be in the table more than once, and it's because the "cityaliasname" (not shown) or some other column differs. But I just want to know which zips are in there more than once because the county column differs. I searched before posting this and I found many questions about counting records but I could not figure out how to apply them to my problem. Please forgive me if there is already a question whose answer applies to this question.

    Read the article

  • wordpress mu theme per-user options

    - by pixeline
    Is it possible to add an options screen to a Wordpress MU theme (options being saved for each user, so blogwide, not sitewide) ? I'm used to program wordpress themes, but i'm a bit puzzled as to how make customization happen in a multi-user environment.

    Read the article

  • Line numbering per paragraph in Word 2007

    - by WaelJ
    How can I use line numbering in Word 2007, but for each paragraph? (By line numbering I mean the one from Page Layout/Setup, not regular list numbering) So something like this: 1 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. 2 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat 3 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat

    Read the article

  • Nhibernate one-to-many with table per subclass

    - by Wayne
    I am customizing N2CMS's database structure, and met with an issue. The two classes are listed below. public class Customer : ContentItem { public IList<License> Licenses { get; set; } } public class License : ContentItem { public Customer Customer { get; set; } } The nhibernate mapping are as follows. <class name="N2.ContentItem,N2" table="n2item"> <cache usage="read-write" /> <id name="ID" column="ID" type="Int32" unsaved-value="0" access="property"> <generator class="native" /> </id> <discriminator column="Type" type="String" /> </class> <subclass name="My.Customer,My" extends="N2.ContentItem,N2" discriminator-value="Customer"> <join table="Customer"> <key column="ItemID" /> <bag name="Licenses" generic="true" inverse="true"> <key column="CustomerID" /> <one-to-many class="My.License,My"/> </bag> </join> </subclass> <subclass name="My.License,My" extends="N2.ContentItem,N2" discriminator-value="License"> <join table="License" fetch="select"> <key column="ItemID" /> <many-to-one name="Customer" column="CustomerID" class="My.Customer,My" not-null="false" /> </join> </subclass> Then, when get an instance of Customer, the customer.Licenses is always empty, but actually there are licenses in the database for the customer. When I check the nhibernate log file, I find that the SQL query is like: SELECT licenses0_.CustomerID as CustomerID1_, licenses0_.ID as ID1_, licenses0_.ID as ID2_0_, licenses0_1_.CustomerID as CustomerID7_0_, FROM n2item licenses0_ inner join License licenses0_1_ on licenses0_.ID = licenses0_1_.ItemID WHERE licenses0_.CustomerID = 12 /* @p0 */ It seems that nhibernate believes that the CustomerID is in the 'n2item' table. I don't know why, but to make it work, I think the SQL should be something like this. SELECT licenses0_.ID as ID1_, licenses0_.ID as ID2_0_, licenses0_1_.CustomerID as CustomerID7_0_, FROM n2item licenses0_ inner join License licenses0_1_ on licenses0_.ID = licenses0_1_.ItemID WHERE licenses0_1_.CustomerID = 12 /* @p0 */ Could any one point out what's wrong with my mappings? And how can I get the correct licenses of one customer? Thanks in advance.

    Read the article

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