Commit Graph

647 Commits

Author SHA1 Message Date
Michael Bayne a5face282b Well, OK. We're going to take the pain and break binary compatibility and use
thsi opportunity to move a whole heap of stuff into impl that doesn't really
need to be visible to external parties. We're changing the return value of all
expression creating factory classes to SQLExpression or FluentExp because those
expose all the functionality one might need on the returned values and there's
otherwise no value to be had getting an And() or a LiteralExp() and a downside
of preventing us from replacing the implementation of those expressions without
breaking binary compatibility.

I hemmed a bit about everything in depot.operator. In theory everything there
is available via a combination of Exps and FluentExp but in practice Whirled
uses a ton of those classes directly (whre a ton is defined as 64 imports of
classes in depot.operator). Perhaps I'll go on a cleanup jihad there and then
move all that to impl as well.

The rabbit holes, they always go deep.
2009-09-10 02:18:38 +00:00
Michael Bayne cf49fbbc9a Let's switch these to less specific return types before they end up out in the
wild.
2009-09-10 00:59:15 +00:00
Michael Bayne 0326468e8e These need to return FunctionExp to be binary compatible. Let this be a
reminder why it can be useful not to return the most specific type possible
from a method, but rather a more general supertype that allows us to change the
internals of the method without losing binary compatibility.
2009-09-10 00:52:23 +00:00
Michael Bayne fce9e56aca Provide these as deprecated for a short while to preserve binary compatibility
for Samsara apps.
2009-09-10 00:34:08 +00:00
Par Winzell 47e6f6f552 Now that we have explicit Ln() and Log10(), let's get rid of the hopelessly esoteric arbitrary-base Log(). 2009-09-09 20:57:08 +00:00
Par Winzell 14c1bdd860 Call the convenience collection Funcs, not Funs. 2009-09-09 20:02:51 +00:00
Par Winzell 92fd3054ca Handle the new Log10 class. 2009-09-09 19:57:58 +00:00
Par Winzell 2ae7d6146b Unintentional commit. 2009-09-09 19:56:11 +00:00
Par Winzell 12fabe42f7 Actually, that can't happen, so let's handle it more gracelessly. 2009-09-09 19:55:43 +00:00
Par Winzell 27dcb0e753 Eclipse-warning tweaks from Charlie. 2009-09-09 19:52:56 +00:00
Par Winzell 9c68929213 It turns out PostgreSQL supports LN(exp) and LOG(exp) in double precision, but not LOG(base, exp). So we're adding an explicit LOG10. I wonder how useful the two-argument one is... maybe we should delete it. 2009-09-09 19:51:33 +00:00
Par Winzell 32bccc3dd7 Deprecate FunctionExp in favour of explicit support for many common SQL functions, whose convenience factory methods reside in com.samskivert.depot.Funs. The EpochSeconds class is also deprecated in favour of Funs.dateEpoch(). 2009-09-09 14:39:55 +00:00
Par Winzell f871b08383 Tiny typo. 2009-09-04 21:36:34 +00:00
Par Winzell 3032a1e568 Connection.isClosed() is new in 1.6 and Connection.close() is a no-op if the connection is already closed, so let's go for brevity here and save people from having to have 1.6-specific JDBC drivers. 2009-09-04 19:06:25 +00:00
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