Correct, using getInsertInto() is the preffered way to do this (shame on me for 
not telling you).
It is in the true spirit of Empire-db that says: If the database can do it, let 
the datbase do it.
So many people implement things in code that a clever sql statement could do 
much more efficiently.

However I don't think that extending initRecord() here is a good idea, simply 
because this is such a special case that it needs special handling and as you 
have found out, one should rather use getInsertInto(). If this is not possible 
then the copying logic is too complex anyway and it must be adressed 
invidiually.
 
We have a wiki for Emprire-db and there are even some query examples there:
http://cwiki.apache.org/confluence/display/empiredb/Query+Building
You are welcome to add more, but I am not sure whether you need write access 
priviledges.

Regards
Rainer


McKinley wrote:
> Re: Copy and Insert DBRecord (Urgent for me)
> 
> On Fri, Jan 15, 2010 at 7:42 PM, Rainer Döbele <[email protected]>
> wrote:
> >
> > I know it is tempting to use initRecord() but it has not been
> designed for doing what you want to do.
> > Rather it should be used for modifying existing records.
> 
> Thanks for your example! I ended up using getInsertInto() which took a
> long time to learn how to use correctly. I think that Empire-db is the
> best thing out there right now, but there is a whole other API that
> could be build on top of it. I would like to come up with methods that
> return better references and generally provide more convenience in
> their arguments. After I have time to figure out the verbose areas of
> my code, I'll present some ideas.
> 
> > IMO the right approach is to create a new record and copy all but pk
> and timestamp columns.
> 
> This should definitely go into a convenience method with optional
> (keepPK, keepTs) arguments in the future. The best way to avoid using
> the wrong method is by finding a more tempting one :)
> 
> Perhaps the best thing for now is to get a wiki for common query
> examples. Is that possible at Apache?
> 
> Thanks again,
> 
> McKinley

Reply via email to