Yes Java does not make it easy to work with Immutable objects. Most people combat this issue with "builders" that make it easier to make the objects.
Protobuf infact does this automatically for you: https://developers.google.com/protocol-buffers/docs/javatutorial There are also several annotation processing libraries: http://code.google.com/p/make-builder/ and http://code.google.com/p/genftw/ At some point I might look into making protobuf generators that have some sort JPA extension. Its unclear how you add meta data to protobuf. Or an annotation processing extension (JSR-269) to JIRM (which is the more likely route). On Sunday, November 4, 2012 11:48:51 AM UTC-5, Stéphane Cl wrote: > > Hi, > > On Sunday, November 4, 2012 4:26:59 PM UTC+1, Adam Gent wrote: >> >> Yeah I was going to put in "/* ... */" support but it ended up making >> the SQL nastier than just forcing you to put the placeholder at the end of >> the line >> plus I don't think all databases support "/* ... */". At some point I >> will probably add it though. >> >> Most of the time for SELECT statements I don't need that many >> placeholders replaced (1-3 on average). >> Where it can get nasty is on INSERT and UPDATE statements but for those >> statements you can use the auto ORM JPA SQL generation. >> >> To tell you the truth I actually like the tedium of new lines and having >> to format your SQL. >> I'm sure you have written INSERT statements where its difficult to match >> up which value goes to which column. >> >> > The idea of real SQL queries and placeholder parameters sound very nice > imho. It would also open the way to POJO generation if you knew just a > little more about the schema. you could also think of running the whole > string in a transaction to test for regression. > > >> For example this is tedious for short INSERTs: >> >> INSERT INTO test_bean >> (string_prop, long_prop, timets) >> VALUES ( >> 'HELLO' -- {stringProp} >> , 3000 -- {longProp} >> , now() -- {timeTS} >> ) >> >> But for really long inserts with many columns its actually convenient. >> >> > But on the java side, wouldn't the principle of immutable POJO force you > to write things like > myNewTestBeanRecord = new TestBean( "Hello", 3000, "World", "Happy", > "New", "Year" (insert a dozen more values here > all-the-same-type-that-are-easily-inverted) )? > > Best > > >
