Search Results

Search found 156 results on 7 pages for 'createcriteria'.

Page 3/7 | < Previous Page | 1 2 3 4 5 6 7  | Next Page >

  • nhibernate : how to intialise child list objects

    - by frosty
    I have the following method in my repository. This works fine, my orderItems are initialised as intended however orderItems contains another collection called OrderItemAddress. These are not initialised. How would i do this? public Model.Order Get(int id) { using (ISession session = NHibernateHelper.OpenSession()) { Model.Order order = session .CreateCriteria(typeof(Model.Order)) .Add(Restrictions.Eq("Id", id)) .UniqueResult<Model.Order>(); NHibernateUtil.Initialize(order.OrderItems); return order; } }

    Read the article

  • Linq Aggregate on object and List

    - by Kris-I
    I do this query with NHibernate: var test = _session.CreateCriteria(typeof(Estimation)) .SetFetchMode("EstimationItems", FetchMode.Eager) .List(); An "Estimation" can have several "EstimationItems" (Quantity, Price and ProductId) I'd like a list of "Estimation" with these constraints : One line by "Estimation" code on the picture (ex : 2011/0001 and 2011/0003) By estimation (means on each line) the number of "EstimationItems" By Estimation (means on each line) the total price (Quantity * Price) for each "EstimationItems" I hope the structure will be clearer with the picture below. Thanks,

    Read the article

  • How to do a NotEqual to in NHibernate

    - by Blankman
    I have an enumeration of type int in my entity, UserStatus. I want to get all users where the UserStatus < Cancelled. So: Session.CreateCriteria(typeof(User)) .Add(Expression.Eq("UserStatus", (int)UserStatus.Cancelled) .UniqueResult<User>(); The above is fore equal, I need to get not equal.

    Read the article

  • What is the fastest findByName query with hibernate?

    - by Karussell
    I am sure I can improve the performance of the following findByName query of hibernate: public List<User> findByName(String name) { session.createCriteria(User.class).add(Restrictions.eq("name", name)).list(); } In which way should I improve it or even more important: in which ways should I improve it first? I will need the full object with all the collections (layz or not) and deps of this class.

    Read the article

  • Select latest group by in nhibernate

    - by Kendrick
    I have Canine and CanineHandler objects in my application. The CanineHandler object has a PersonID (which references a completely different database), an EffectiveDate (which specifies when a handler started with the canine), and a FK reference to the Canine (CanineID). Given a specific PersonID, I want to find all canines they're currently responsible for. The (simplified) query I'd use in SQL would be: Select Canine.* from Canine inner join CanineHandler on(CanineHandler.CanineID=Canine.CanineID) inner join (select CanineID,Max(EffectiveDate) MaxEffectiveDate from caninehandler group by CanineID) as CurrentHandler on(CurrentHandler.CanineID=CanineHandler.CanineID and CurrentHandler.MaxEffectiveDate=CanineHandler.EffectiveDate) where CanineHandler.HandlerPersonID=@PersonID Edit: Added mapping files below: <class name="CanineHandler" table="CanineHandler" schema="dbo"> <id name="CanineHandlerID" type="Int32"> <generator class="identity" /> </id> <property name="EffectiveDate" type="DateTime" precision="16" not-null="true" /> <property name="HandlerPersonID" type="Int64" precision="19" not-null="true" /> <many-to-one name="Canine" class="Canine" column="CanineID" not-null="true" access="field.camelcase-underscore" /> </class> <class name="Canine" table="Canine"> <id name="CanineID" type="Int32"> <generator class="identity" /> </id> <property name="Name" type="String" length="64" not-null="true" /> ... <set name="CanineHandlers" table="CanineHandler" inverse="true" order-by="EffectiveDate desc" cascade="save-update" access="field.camelcase-underscore"> <key column="CanineID" /> <one-to-many class="CanineHandler" /> </set> <property name="IsDeleted" type="Boolean" not-null="true" /> </class> I haven't tried yet, but I'm guessing I could do this in HQL. I haven't had to write anything in HQL yet, so I'll have to tackle that eventually anyway, but my question is whether/how I can do this sub-query with the criterion/subqueries objects. I got as far as creating the following detached criteria: DetachedCriteria effectiveHandlers = DetachedCriteria.For<Canine>() .SetProjection(Projections.ProjectionList() .Add(Projections.Max("EffectiveDate"),"MaxEffectiveDate") .Add(Projections.GroupProperty("CanineID"),"handledCanineID") ); but I can't figure out how to do the inner join. If I do this: Session.CreateCriteria<Canine>() .CreateCriteria("CanineHandler", "handler", NHibernate.SqlCommand.JoinType.InnerJoin) .List<Canine>(); I get an error "could not resolve property: CanineHandler of: OPS.CanineApp.Model.Canine". Obviously I'm missing something(s) but from the documentation I got the impression that should return a list of Canines that have handlers (possibly with duplicates). Until I can make this work, adding the subquery isn't going to work... I've found similar questions, such as http://stackoverflow.com/questions/747382/only-get-latest-results-using-nhibernate but none of the answers really seem to apply with the kind of direct result I'm looking for. Any help or suggestion is greatly appreciated.

    Read the article

  • invoke sql function using nhibernate?

    - by net205
    I want to query like this: select * from table where concat(',', ServiceCodes, ',') like '%,33,%'; select * from table where (','||ServiceCodes||',') like '%,33,%'; so, I wrote this code: ICriteria cri = NHibernateSessionReader.CreateCriteria(typeof(ConfigTemplateList)); cri.Add(Restrictions.Like(Projections.SqlFunction("concat", NHibernateUtil.String, Projections.Property("ServiceCodes")), "%,33,%")); I get sql similar : select * from table where (ServiceCodes) like '%,33,%'; But it is not what I want,how to do it??? thanks!

    Read the article

  • hibernate - uniqueResult silently fails

    - by robinmag
    I have a login controller that use the hibernate uniqueResult method. Everything works fine when i test it in eclipse's tomcat server. But when i deploy my webapps to tomcat server (on the same machine) it fails: it always returns null even i use the correct credential. Here is my hibernate code: session.createCriteria(User.class) .add(Restrictions.eq(User.USERNAME_FIELD, userName)) .add(Restrictions.eq(User.PASSWORD_FIELD, password)).uniqueResult(); Thank you!

    Read the article

  • Are NHibernate lists loaded on demand?

    - by André Pena
    This is a pretty simple question. When I do this: session.CreateCriteria(typeof(Product)).List(); The resulting list will load as I access it? Let's say, from 100 to 100 elements for example? Or will it load all once? In the case it's not "virtual" how can I make it so? What's the best pratice about it? Thanks;

    Read the article

  • hibernate search and projection - different fields on different objects

    - by Odelya
    Hi! I have the following code: Criteria crit = sess.createCriteria(Product.class); ProjectionList proList = Projections.projectionList(); proList.add(Projections.property("name")); proList.add(Projections.property("price")); crit.setProjection(proList); But I also have User.class and I would like the name to be restricted on User.class and price from Product class. How can I restrict different columns on different objects in Hibernate Search?

    Read the article

  • How can you remove a Criterion from a criteria?

    - by ChuckM
    Hello, For instance if I do something like: Criteria c = session.createCriteria(Book.class) .add(Expression.ge("release",reDate); .add(Expression.ge("price",price); .addOrder( Order.asc("date") ) .setFirstResult(0) .setMaxResults(10); c.list(); How can I use the same criteria instance, but remove (for example) the second criterion? I'm trying to build a dynamic query in which I'd like to let the user remove a filter, without the backend having to reconstruct the criteria from scratch. Thank you

    Read the article

  • how can i display the database data to an jtable(dynamic) in the swings!

    - by harish0510
    we are using hibernate in business layer,but the task is, by using the jtable in swings to display the dynamic data(swings) from the database. code: Criteria criteria=session.createCriteria(User.class); //here user.class is pojo class in hibernate. List studentlist= criteria.list(); System.out.println("records"+studentlist); here the data is showing in hibernate console, but how to represent that data in the format of "jtable".

    Read the article

  • how can i display the list data to an jtable in the swings!

    - by harish0510
    we are doing hibernate project,then problem is we want to display the users list from the database to userinterface by jtable concept. so, we are not able to display the data using jtable? code: Criteria criteria=session.createCriteria(User.class);//user is pojo class List studentlist= criteria.list(); System.out.println("records"+studentlist);// we want to display the list data to jtable.

    Read the article

  • Need some help with a NHibernate Query

    - by cwap
    Hi all Say I got 3 entities: Business, Employee and Payment. A payment has a foreign key to an Employee, while the Employee has an foreign key to a business. Now, I want to create a query which gives me all payments for a given business. I really don't have a clue about how to do this - I guess I want something like: mySession.CreateCriteria<Payment>() .Add(Criterion.Expression.Eq(/* Employee_FK => Employee.Business_FK == BusinessID */); Any help would be greatly appreciated :)

    Read the article

  • Nhiberate, multiple tables, same class

    - by jeff
    It's been asked a million times, its like this. Say Invoice is the base class and InvoiceHistory is the class that simply inherits from Invoice. When I do something like invoiceList = session.CreateCriteria(typeof(Invoice)).List(); I get everything from Invoice (that I want, plus everything from InvoiceHistory). Do I need to have an InvoiceBase and create derived versions for Invoice and InvoiceHistory?

    Read the article

  • How to make NOT IN statement via Restrictions

    - by slavig
    I used this trick: List statuses = new ArrayList(); Criteria criteria = session.createCriteria(MessageQueue.class); criteria.add(Restrictions.not(Restrictions.in("message_status", statuses))); and this code creates: ...from MESSAGE_QUEUE mq where not (mq.message_status in (?, ?, ?, ?))... but I need: ...from MESSAGE_QUEUE mq where mq.message_status NOT IN (?, ?, ?, ?) Du you think they are equal statements?

    Read the article

  • Problem with NHibernate

    - by Bernard Larouche
    I am trying to get a list of Products that share the Category. NHibernate returns no product which is wrong. Here is my Criteria API method : public IList<Product> GetProductForCategory(string name) { return _session.CreateCriteria(typeof(Product)) .CreateCriteria("Categories") .Add(Restrictions.Eq("Name", name)) .List<Product>(); } Here is my HQL method : public IList<Product> GetProductForCategory(string name) { return _session.CreateQuery("select from Product p, p.Categories.elements c where c.Name = :name").SetString("name",name).List<Product>(); } Both methods return no product when they should return 2 products. Here is the Mapping for the Product class : <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="CBL.CoderForTraders.DomainModel" namespace="CBL.CoderForTraders.DomainModel"> <class name="Product" table="Products" > <id name="_persistenceId" column="ProductId" type="Guid" access="field" unsaved-value="00000000-0000-0000-0000-000000000000"> <generator class="assigned" /> </id> <version name="_persistenceVersion" column="RowVersion" access="field" type="int" unsaved-value="0" /> <property name="Name" column="ProductName" type="String" not-null="true"/> <property name="Price" column="BasePrice" type="Decimal" not-null="true" /> <property name="IsTaxable" column="IsTaxable" type="Boolean" not-null="true" /> <property name="DefaultImage" column="DefaultImageFile" type="String"/> <bag name="Descriptors" table="ProductDescriptors"> <key column="ProductId" foreign-key="FK_Product_Descriptors"/> <one-to-many class="Descriptor"/> </bag> <bag name="Categories" table="Categories_Products" > <key column="ProductId" foreign-key="FK_Products_Categories"/> <many-to-many class="Category" column="CategoryId"></many-to-many> </bag> <bag name="Orders" generic="true" table="OrderProduct" > <key column="ProductId" foreign-key="FK_Products_Orders"/> <many-to-many column="OrderId" class="Order" /> </bag> </class> </hibernate-mapping> And finally the mapping for the Category class : <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="CBL.CoderForTraders.DomainModel" namespace="CBL.CoderForTraders.DomainModel" default-access="field.camelcase-underscore" default-lazy="true"> <class name="Category" table="Categories" > <id name="_persistenceId" column="CategoryId" type="Guid" access="field" unsaved-value="00000000-0000-0000-0000-000000000000"> <generator class="assigned" /> </id> <version name="_persistenceVersion" column="RowVersion" access="field" type="int" unsaved-value="0" /> <property name="Name" column="Name" type="String" not-null="true"/> <property name="IsDefault" column="IsDefault" type="Boolean" not-null="true" /> <property name="Description" column="Description" type="String" not-null="true" /> <many-to-one name="Parent" column="ParentID"></many-to-one> <bag name="SubCategories" inverse="true"> <key column="ParentID" foreign-key="FK_Category_ParentCategory" /> <one-to-many class="Category"/> </bag> <bag name="Products" table="Categories_Products"> <key column="CategoryId" foreign-key="FK_Categories_Products" /> <many-to-many column="ProductId" class="Product"></many-to-many> </bag> </class> </hibernate-mapping> Can you see what could be the problem ?

    Read the article

  • Projections.count() and Projections.countDistinct() both result in the same query

    - by Kim L
    EDIT: I've edited this post completely, so that the new description of my problem includes all the details and not only what I previously considered relevant. Maybe this new description will help to solve the problem I'm facing. I have two entity classes, Customer and CustomerGroup. The relation between customer and customer groups is ManyToMany. The customer groups are annotated in the following way in the Customer class. @Entity public class Customer { ... @ManyToMany(mappedBy = "customers", fetch = FetchType.LAZY) public Set<CustomerGroup> getCustomerGroups() { ... } ... public String getUuid() { return uuid; } ... } The customer reference in the customer groups class is annotated in the following way @Entity public class CustomerGroup { ... @ManyToMany public Set<Customer> getCustomers() { ... } ... public String getUuid() { return uuid; } ... } Note that both the CustomerGroup and Customer classes also have an UUID field. The UUID is a unique string (uniqueness is not forced in the datamodel, as you can see, it is handled as any other normal string). What I'm trying to do, is to fetch all customers which do not belong to any customer group OR the customer group is a "valid group". The validity of a customer group is defined with a list of valid UUIDs. I've created the following criteria query Criteria criteria = getSession().createCriteria(Customer.class); criteria.setProjection(Projections.countDistinct("uuid")); criteria = criteria.createCriteria("customerGroups", "groups", Criteria.LEFT_JOIN); List<String> uuids = getValidUUIDs(); Criterion criterion = Restrictions.isNull("groups.uuid"); if (uuids != null && uuids.size() > 0) { criterion = Restrictions.or(criterion, Restrictions.in( "groups.uuid", uuids)); } criteria.add(criterion); When executing the query, it will result in the following SQL query select count(*) as y0_ from Customer this_ left outer join CustomerGroup_Customer customergr3_ on this_.id=customergr3_.customers_id left outer join CustomerGroup groups1_ on customergr3_.customerGroups_id=groups1_.id where groups1_.uuid is null or groups1_.uuid in ( ?, ? ) The query is exactly what I wanted, but with one exception. Since a Customer can belong to multiple CustomerGroups, left joining the CustomerGroup will result in duplicated Customer objects. Hence the count(*) will give a false value, as it only counts how many results there are. I need to get the amount of unique customers and this I expected to achieve by using the Projections.countDistinct("uuid"); -projection. For some reason, as you can see, the projection will still result in a count(*) query instead of the expected count(distinct uuid). Replacing the projection countDistinct with just count("uuid") will result in the exactly same query. Am I doing something wrong or is this a bug? === "Problem" solved. Reason: PEBKAC (Problem Exists Between Keyboard And Chair). I had a branch in my code and didn't realize that the branch was executed. That branch used rowCount() instead of countDistinct().

    Read the article

  • Grails GORM (Hibernate) query

    - by bsreekanth
    Hello, I'm trying to do the below sql statement in GORM select * from table1 where table1.x not in (select x from table 2 where y='something'); so, I have two tables, and needs to find the entries from table 1 which are not in table 2. In Grails def xx= table2.findByY('something') def c = table1.createCriteria() def result= c.list { not ( in('x', xx) ) } the syntax is wrong, and I'm not sure how to simulate not in sql logic. As a learning point, if someone can also tell me why minus (-) operator in grails/groovy doesn't work with list. I tried getting x and y seperately, and doing x.minus(y), but it doesn't change the list. I saw an explanation at http://stackoverflow.com/questions/1754576/groovy-on-grails-list-not-working , but I would expect the list defined are local. thank you so much.

    Read the article

  • NHibernate, could not load an entity when column exists in the database.

    - by Eitan
    This is probably a simple question to answer but I just can't figure it out. I have a "Company" class with a many-to-one to "Address" which has a many to one to a composite id in "City". When I load a "Company" it loads the "Address", but if I call any property of "Address" I get the error: {"could not load an entity: [IDI.Domain.Entities.Address#2213][SQL: SELECT address0_.AddressId as AddressId13_0_, address0_.Street as Street13_0_, address0_.floor as floor13_0_, address0_.room as room13_0_, address0_.postalcode as postalcode13_0_, address0_.CountryCode as CountryC6_13_0_, address0_.CityName as CityName13_0_ FROM Address address0_ WHERE address0_.AddressId=?]"} The inner exception is: {"Invalid column name 'CountryCode'.\r\nInvalid column name 'CityName'."} What I don't understand is that I can run the query in sql server 2005 and it works, furthermore both those columns exist in the address table. Here are my HBMs: <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="IDI.Domain" namespace="IDI.Domain.Entities" > <class name="IDI.Domain.Entities.Company,IDI.Domain" table="Companies"> <id column="CompanyId" name="CompanyId" unsaved-value="0"> <generator class="native"></generator> </id> <property column="Name" name="Name" not-null="true" type="String"></property> <property column="NameEng" name="NameEng" not-null="false" type="String"></property> <property column="Description" name="Description" not-null="false" type="String"></property> <property column="DescriptionEng" name="DescriptionEng" not-null="false" type="String"></property> <many-to-one name="Address" column="AddressId" not-null="false" cascade="save-update" class="IDI.Domain.Entities.Address,IDI.Domain"></many-to-one> <property column="Telephone" name="Telephone" not-null="false" type="String"></property> <property column="TelephoneTwo" name="TelephoneTwo" not-null="false" type="String"></property> <property column="Fax" name="Fax" not-null="false" type="String"></property> <property column="ContactMan" name="ContactMan" not-null="false" type="String"></property> <property column="ContactManEng" name="ContactManEng" not-null="false" type="String"></property> <property column="Email" name="Email" not-null="false" type="String"></property> </class> </hibernate-mapping> <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="IDI.Domain" namespace="IDI.Domain.Entities" > <class name="IDI.Domain.Entities.Address,IDI.Domain" table="Address"> <id name="AddressId" column="AddressId" type="Int32"> <generator class="native"></generator> </id> <property name="Street" column="Street" not-null="false" type="String"></property> <property name="Floor" column="floor" not-null="false" type="Int32"></property> <property name="Room" column="room" not-null="false" type="Int32"></property> <property name="PostalCode" column="postalcode" not-null="false" type="string"></property> <many-to-one class="IDI.Domain.Entities.City,IDI.Domain" name="City" update="false" insert="false"> <column name="CountryCode" sql-type="String" ></column> <column name="CityName" sql-type="String"></column> </many-to-one> </class> </hibernate-mapping> <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="IDI.Domain" namespace="IDI.Domain.Entities" > <class name="IDI.Domain.Entities.City,IDI.Domain" table="Cities"> <composite-id> <key-many-to-one class="IDI.Domain.Entities.Country,IDI.Domain" name="CountryCode" column="CountryCode"> </key-many-to-one> <key-property name="Name" column="Name" type="string"></key-property> </composite-id> </class> </hibernate-mapping> Here is my code that calls the Company: IList<BursaUser> user; if(String.IsNullOrEmpty(email) && String.IsNullOrEmpty(company)) return null; ICriteria criteria = Session.CreateCriteria(typeof (BursaUser), "user").CreateCriteria("Company", "comp"); if(String.IsNullOrEmpty(email) || String.IsNullOrEmpty(company) ) { user = String.IsNullOrEmpty(email) ? criteria.Add(Expression.Eq("comp.Name", company)).List<BursaUser>() : criteria.Add(Expression.Eq("user.Email", email)).List<BursaUser>(); } And finally here is where i get the error: "user" was already initialized with the code above: if (user.Company.Address.City == null) user.Company.Address.City = new City(); Thanks.

    Read the article

  • Nhibernate Criteria Group By clause and select other data that is not grouped

    - by Peter R
    Hi, I have a parent child relationship, let's say class and children. Each child belongs to a class and has a grade. I need to select the children (or the ids of the children) with the lowest grade per class. session.CreateCriteria(typeof(Classs)) .CreateAlias("Children", "children") .SetProjection(Projections.ProjectionList() .Add(Projections.Min("children.Grade")) .Add(Projections.GroupProperty("Id")) ) .List<Object[]>(); This query returns me the lowest grade per class, but I don't know which child got the grade. When I add the children's Id to the group, the group is wrong and every child gets returned. I was hoping we could just select get the id's of those childs without grouping them. If this is not possible, then maybe there is a way to solve this with subqueries?

    Read the article

  • NHibernate: Subqueries.Exists not working

    - by cbp
    I am trying to get sql like the following using NHibernate's criteria api: SELECT * FROM Foo WHERE EXISTS (SELECT 1 FROM Bar WHERE Bar.FooId = Foo.Id AND EXISTS (SELECT 1 FROM Baz WHERE Baz.BarId = Bar.Id) So basically, Foos have many Bars and Bars have many Bazes. I want to get all Foos that have Bars with Bazes. To do this, a detached criteria seems best, like this: var subquery = DetachedCriteria.For<Bar>("bar") .SetProjection(Projections.Property("bar.Id")) .Add(Restrictions.Eq("bar.FooId","foo.Id")) // I have also tried replacing "bar.FooId" with "bar.Foo.Id" .Add(Restrictions.IsNotEmpty("bar.Bazes")); return Session.CreateCriteria<Foo>("foo") .Add(Subqueries.Exists(subquery)) .List<Foo>(); However this throws the exception: System.ArgumentException: Could not find a matching criteria info provider to: bar.FooId = foo.Id and bar.Bazes is not empty Is this a bug with NHibernate? Is there a better way to do this?

    Read the article

  • Order by null/not null with ICriteria

    - by Kristoffer
    I'd like to sort my result like this: First I want all rows/objects where a column/property is not null, then all where the colmn/property is null. Then I want to sort by another column/property. How can I do this with ICriteria? Do I have to create my own Order class, or can it be done with existing code? ICriteria criteria = Session.CreateCriteria<MyClass>() .AddOrder(Order.Desc("NullableProperty")) // What do I do here? IProjection? Custom Order class? .AddOrder(Order.Asc("OtherProperty"));

    Read the article

  • NHibernate ICriteria with a bag

    - by plunk
    Hi, Just a quick question. If I've got 2 tables that are joined in a 3rd table with a many-to-many relationship, is it possible to write an ICriteria with expressions in one of the tables and the join table? Lets say the mapping file looks something like: <bag name ="Bag" table="JoinTable" cascade ="none"> <key column="Data_ID"/> <many-to-many class="Data2" column="Data2_ID"/> </bag> Is it then possible to write an ICriteria like the following? ICriteria crit = session.CreateCriteria(typeof(Data)); crit.Add(Expression.Eq("Name", name)); crit.Add(Expression.Between("Date", startDate, endDate)); crit.Add(Expression.Eq("Bag", data2IDNumber)); When I try this, it tells me I the expected type is IList, whereas the actual type is Bag. Thanks.

    Read the article

  • NHibernate Projection Components

    - by reggieboyYEAH
    Hello guys im trying to hydrate a DTO using projections in NHibernate this is my code IList<PatientListViewModel> list = y.CreateCriteria<Patient>() .SetProjection(Projections.ProjectionList() .Add(Projections.Property("Birthdate"), "Birthdate") .Add(Projections.Property("Doctor.Id"), "DoctorId") .Add(Projections.Property("Gender"), "Gender") .Add(Projections.Property("Id"), "PatientId") .Add(Projections.Property("Patient.Name.Fullname"), "Fullname") ) .SetResultTransformer(Transformers.AliasToBean<PatientListViewModel>()) .List<PatientListViewModel>(); this code is throwing an exception? anyone know what is the problem? here is the error message Message: could not resolve property: Patient.Name.Fullname of: OneCare.Domain.Entities.Patient

    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

< Previous Page | 1 2 3 4 5 6 7  | Next Page >