Commit Graph

633 Commits

Author SHA1 Message Date
Michael Bayne 82d742ec09 A (slightly modified) patch from Charlie to use the magical statement
collecting Connection to automatically close all statements created during the
course of our operations.
2009-09-04 17:37:57 +00:00
Par Winzell 52a9c2036f Charlie's commit patch; if we're not in the auto-commit state, let Depot explicitly commit its operations. If we add transaction awareness to Depot in some future, this behaviour might become more subtle. 2009-09-03 22:12:44 +00:00
Michael Bayne f9eb364c7f Formatting tidying. 2009-08-21 01:50:21 +00:00
Michael Bayne 157d339906 Provide a generic key element extraction higher-order function that works for
any element type at any index.
2009-08-20 01:07:57 +00:00
Michael Bayne b43ca1e203 We no longer need to export a GWT jar file. 2009-08-18 22:07:07 +00:00
Michael Bayne 928926d5e1 Use ByteEnum from samskivert. This is going to break a bunch of stuff which Ray
or I will fix. Whee!
2009-08-18 22:04:04 +00:00
Michael Bayne c6ae109f19 Some code hygeine from Charlie. 2009-08-17 21:06:57 +00:00
Michael Bayne 4a48875b7f Nixed unused imports, unneeded cast. 2009-08-17 07:32:34 +00:00
Michael Bayne 1f0c33eacf Improved error message. 2009-08-07 03:11:37 +00:00
Michael Bayne 363614dff5 Zell may want to refute that this is a good idea, but if I try to order by a
computed field in a computed record, Depot freaks out because it doesn't know
what table the computed field comes from when it doesn't come from any table.

So clearly this is what we want to achieve that functionality, but what I'm not
100% sure about is what ass biting we're opening ourselves up to here by not
freaking out in this case. We may be taking a step backwards in terms of useful
error reporting if someone does something stupid with computed fields. But
we'll just have to see what those errors are when they crop up. If the database
can't figure out what we're talking about with the unqualified field name, it
too will freak out.
2009-08-07 02:49:20 +00:00
Michael Bayne 37295dbcb3 Added Exps.count() and Exps.countDistinct() and the necessary plumbing to sneak
a 'distinct' into the argument list of the count() invocation.
2009-08-07 01:58:58 +00:00
Michael Bayne a52abcc7b2 Allow FieldOverride to be constructed with a ColumnExp. 2009-08-07 01:36:40 +00:00
Michael Bayne 0c7a8a5f01 Added sum() and abs(). 2009-08-07 01:24:10 +00:00
Michael Bayne 2ee38910c6 Allow a Key<T> to be invalidated directly and create the KeyCacheKey for the
caller.
2009-07-30 23:23:18 +00:00
Michael Bayne e876ff0832 Step one in making Depot's caching classloader friendly: make the keys use only
system classes (not 100% done, if you use a ByteEnum in a key right now it
doesn't do the right thing). Also moved SimpleCacheKey into impl because it's
an implementation detail, not meant to be used by external parties.
2009-07-30 22:06:18 +00:00
Par Winzell c0b031a36d Remove unused imports. 2009-07-28 16:11:53 +00:00
Michael Bayne a64f465990 We need these codes to be consistent across VMs in the cache network. 2009-07-17 22:21:11 +00:00
Michael Bayne 05c9e52bfb Revamp of cache management. We need our cache adapter to create our caches for
us so that if we use multiple PersistenceContexts in the same VM they don't all
point to the same cache buckets which causes badness. At some point we'll
probably have to make it easier to customize these configurations, but this
should work for now.
2009-07-17 22:11:06 +00:00
Michael Bayne a83bca4bc1 Compromise with Mr Greenwell and provide a Collection which is still somewhat
indicative to the caller that they're not just getting another array list back
but rather a magical lazily converted list but is more useful than Iterable.
2009-07-14 21:15:06 +00:00
Michael Bayne 4839512173 Trim long line. 2009-07-13 06:58:52 +00:00
Michael Bayne f44f49aa49 We no longer care about Velocity. 2009-07-13 06:58:33 +00:00
Michael Bayne fb6d6df3ea Added Key.toInt() which returns a function that can be used to extract the
integer primary key from a Key<T> for records whose primary key is a single
integer.
2009-07-13 03:09:51 +00:00
Michael Bayne 8be8037578 Out with commons-io. 2009-07-12 21:37:44 +00:00
Michael Bayne 1daac11a36 We don't really need Velocity here, we just want some simple key/value
substitutions. Ditch our dependency on the sometimes fragile and frequently
annoying template engine and do things the old fashioned way.
2009-07-11 21:35:19 +00:00
Michael Bayne c1166e0f4a Nixed unused import. 2009-07-11 21:26:43 +00:00
Michael Bayne 21ceb241b4 Throw a BuildException if Velocity fails so that we don't write bogus data back
out to the source file.
2009-07-11 21:26:33 +00:00
Michael Bayne bc7a31c661 When we shutdown our EHCacheAdapter, go through and flush everything from
memory so that if we turn around and recreate a PersistenceContext with a brand
new classloader and start loading things from the cache, we don't have
freakoutery because there's a record in memory that was resolved with the old
classloader. Plus it allows those old classloaders to get collected.
2009-07-10 23:29:36 +00:00
Michael Bayne 2336246b40 Error message improvement. 2009-07-10 22:17:46 +00:00
Michael Bayne 475e0861af CountRecord is widely useful. Let's have Depot provide it. 2009-07-10 21:47:40 +00:00
Michael Bayne 9fd87441ac Added ByteEnumUtil for all your fromByte() needs, included it in the GWT jar in
case you need to do it in the land of gwit.
2009-07-10 20:37:57 +00:00
Michael Bayne 9469575ad7 We don't need the fromByte() method, we can just do what the implementation of
all of our fromByte() methods already do which is iterate over the Enum and
find the one with the right byte. If we care about performance (which we don't
because this is trivial since all of these enums are small), we could even
cache a mapping from byte to enum in the field marshaller. No need to foist
this reponsibility on the ByteEnum implementor.
2009-07-10 17:20:57 +00:00
Michael Bayne def3d652ad Beans/frank. 2009-07-10 03:28:02 +00:00
Michael Bayne 4b4ff40ee5 We need to allow persistent fields to not exist for longer because we may be
using magical methods to convert to/from composite runtime fields.
2009-07-10 00:05:37 +00:00
Michael Bayne 65f4c8dff4 This is possibly getting a little too jiggy, but I'm having all Depot methods
that return a collection return an XList which extends List and adds the
method:

    public <R> Iterable<R> map (Function<T, R> mapper);

which allows you to do things the following:

    return findAll(CategoryRecord.class,
                   new Where(CategoryRecord.PARENT_ID.eq(parentId))).
            map(CategoryRecord.TO_CATEGORY);

which is sufficiently awesome that I think it merits taking these liberties.
Plus it opens the door to adding other transformations that one might want to
do with a collection just loaded from the database.
2009-07-09 20:02:00 +00:00
Michael Bayne 4c697b06a4 Allow a null persistent record to be tranformed to a null runtime record, and
fail immediately when trying to transform a null runtime record to a persistent
record.
2009-07-09 19:50:22 +00:00
Michael Bayne 7dd164525b More magic! We now automatically convert between java.sql.Timestamp,
java.sql.Date and java.util.Date and we support custom getters and setters to
do fancier aggregate conversion (multiple persistent fields into a single
runtime field and/or creation of partially initialized runtime objects from the
available persistent data).
2009-07-08 22:10:07 +00:00
Michael Bayne a113b5d85b We only want non-static, public fields. 2009-07-06 21:55:31 +00:00
Michael Bayne 6ca5f2e4e7 Utilities for creating magical mapping functions that use reflection. 2009-07-06 21:41:29 +00:00
Michael Bayne c0eab0a4c3 Bye bye old adaptation. 2009-07-06 16:53:16 +00:00
Michael Bayne 858bf4ab1c Allow shutdown() to NOOP if we were never init()ed. 2009-07-04 18:39:02 +00:00
Michael Bayne b8696e0060 Added like(). 2009-06-11 17:49:43 +00:00
Michael Bayne d91f968062 Let's not be grouchy about this. Empty ins are probably uncommon and it's
foolish to complicate a bunch of client code. Either we'll do some magical
optimization on the Depot side and not even send queries to the server that we
know can't match anything, or we'll just suck it up and occasionally send a
query to the database that we know will match no rows. C'est la vie.
2009-06-10 21:52:55 +00:00
Michael Bayne b3ee76f914 Added FooRecord.FOO_ID.join(BarRecord.FOO_ID). 2009-06-10 21:07:07 +00:00
Michael Bayne 1e5c201501 Javadocs. 2009-06-10 20:59:34 +00:00
Michael Bayne 6d520a33d6 Oops, those should be static. 2009-06-10 20:58:55 +00:00
Michael Bayne f57795c48f More import relief: add builder classes Ops and Exps which have methods for
creating common operators and expressions that don't fit nicely into the fluent
style. For example: Ops.and(expr1, expr2) is preferable to expr1.and(expr2)
and Ops.not(expr) is definitely nicer than expr.not() (which we don't even
provide).
2009-06-10 20:58:12 +00:00
Michael Bayne 03ac710d4f Yet more fluency. 2009-06-10 18:39:56 +00:00
Michael Bayne 3cc29e08b9 More fluency. 2009-06-10 18:37:28 +00:00
Michael Bayne d4a376e78b FluentExpression -> FluentExp, made a few other base expressions fluent. 2009-06-10 18:35:07 +00:00
Michael Bayne d1e8ed43e2 Added in(). 2009-06-10 17:42:52 +00:00