Can I configure Hiberate / NHibernate not to use the default constructor to create objects when reading from the database?
When Hibernate reads 10 clients from a table, it creates 10 Customerobjects. He does it with
Customer c = new Customer();
Is it possible to do the following instead of Hibernate:
Customer c = ACertainStaticFactory.CreateNewCustomer();
or even to manage a factory instance:
ACertainFactory factory = .....;
Customer c = factory.CreateNewCustomer();
or even more complicated, pass the parameter that I set earlier:
Query query = session.CreateQuery(...);
query.SetSomeParameter(someObject);
session.SetSomeParameter(someObject);
query.List();
Customer c = new Customer(someObject);
Customer c = ACertainStaticFactory.CreateNewCustomer(someObject);
Is this possible anyway? If yes: how? If not: is there an alternative?
source
share