Max Rydahl Andersen wrote:

I don't follow your idea in #2 and #3 - is it related to StatelessSession ?

/max


This is new work for 3.1 that I've not seen. I've just taken a look through the interface, from what I'm understanding this looks great to deal with whole objects at a time.

What I'm trying to address is the ability for partial row insert / update support that the application programmer can control. At the same time allow for SQL server side magic values to fill columns. I see the two goals related and sharing certain requirements.

For example default column value generation for SQL rows during insert. Make hibernate perform a partial insert and if necessary read back the value (if the application read's that property) this readback would be configurable to "always" or "lazy". Then it should be possible to mark any property as subject to server side magic for insert, for update or for both insert/update and then modes of always, only when column is assigned, only when the column is assigned NULL.

From this it should be possible to make use of SQL server specific functions to compute the value of a field on a statement by statement basis. If hibernate resolves that this colum for this statement is subject to server side computation.

This then leads on to being able to have a named server side function library, HSQL fragment that could be used as rvalues. This makes porting an application to a different SQL server is simply a case of replacing the function library, aleviating the need to audit the application code in most places. Much like the SQL dialects do for regular SQL grammer.


Issues for this API:
* If we want the option to optimize away the SELECT (read back) we need to ensure the class the application works with after the operation is a proxy, set to lazy load some properties but not others. This might mean usage like:

rec = hfoo.saveOrUpdate(rec);

That would allow for replacement of a hard class for a proxy where lazy properties are in use or readback=always is not set.



I wouldn't expect this to change the existing APIs that deal with whole objects and no magic, a fallback of readback=always could be the default and not break any existing applications.

I'm trying think through a nice clean API for the application developer that can cover these issues.



brain fart throughts on two API approaches to the same problem:

PartialObject p = hsession.instatePartialObject();
MyObject obj = p.instateDetachedInstance(MyObject.class);
// We now have an empty proxy of our object that tracks property by property
// dirty status, only touched and mandatory (key) columns are initialised
// by the resulting partial SQL statement.
obj.setMyValueOne(1);
obj.setMyValueTwo(null);

p.save(obj);
// This generates a partial insert like:
// INSERT INTO my_object SET id=IDENTITY, my_value.one=1, my_value_two=NULL;
// even though the table has other columns, maybe like my_value_three

long id = obj.getId();

// During this property lookup hibernate would lazy re-load this SQL server generated value
System.out.println("my_value_three = " + obj.getMyValueThree());




Another approach that could work as well as the above to cover other cases:

MyObject myObject = new MyObject();
myObject.setId(1);
myObject.setMyValue(2);
myObject.setAnotherValue("foobar");
myObject.setThirdValue("three");
myObject.setIgnoredValue("I did not mark this as interesting so hibernate will ignore this bogus value");

PartialObject p = hsession.instatePartialObject();
PropertyControlObject pcr = p.createPropertyControlObject(myObject.class);
// This control object tracks dirty status
pcr.addInterestedColumn("my_value"); // by column name
pcr.addInterestedProperty("anotherValue"); // by object property name
pcr.addInterestedPropertyNativeSQL("thirdValue", "SERVER_FUNC(?)", "foo");
p.saveOrUpdate(myObject, pcr);

--
Darryl L. Miles




-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
hibernate-devel mailing list
hibernate-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to