Commit Graph

449 Commits

Author SHA1 Message Date
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 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
Michael Bayne c8417a366e Added bitAnd and bitOr. 2009-06-10 17:29:16 +00:00
Michael Bayne 12e612fe34 OMG I can't believe I didn't think of this earlier: provide fluent builder
methods for expressions. Now you can do FooRecord.BAR.eq(5) instead of new
Equals(FootRecord.BAR, 5), which also saves you the Equals import. Added
methods for operators, some are probably missing and some don't make sense.
I'll fill this out more as I discover where else this style is useful.
2009-06-10 17:27:10 +00:00
Michael Bayne b029dfd6cd Javadoc and import cleanup. 2009-06-10 17:20:31 +00:00
Par Winzell fce2c05f9b So, milli/nano is 1E6, not 1E3, thanks Ray. 2009-06-03 18:49:45 +00:00
Michael Bayne bde9404ca5 Oh Java, I do wish that Map.get() took K not Object. 2009-05-29 23:43:50 +00:00
Michael Bayne 83a4149cbf Fix array indexing booches. 2009-05-29 23:15:04 +00:00
Michael Bayne 79c6f364fa Javadoc and variable naming improvements. 2009-05-29 22:24:58 +00:00
Michael Bayne a8da0d960f Those need to be Object because they could be (probably are in fact)
SQLExpression instances.
2009-05-29 22:16:37 +00:00
Michael Bayne c46741cbe2 Let's make the varargs version of updatePartial a little safer by requiring a
typed (ColumnExp, Comparable) as our first pair of arguments and only let you
get jiggy after that.
2009-05-29 22:14:19 +00:00
Michael Bayne 3062afe1b5 updateLiteral -> updatePartial. It's all partial updates now and you can either
pass in a map or use the varargs methods.
2009-05-29 21:54:12 +00:00
Michael Bayne 962a9cfb5a No String[]. Use ColumnExp[] all the way down. Now that things are getting
tidier, it's a shame that ColumnExp is named as it is because really it's a
FieldExp as it represents the name of the Java object field, not the actual
name of the column which may be something different (if you use
@Column(name="foo")). Maybe next time.
2009-05-29 21:40:17 +00:00
Michael Bayne 08122cda8b Nixed a bit more unneeded parameterized typing. 2009-05-29 21:04:26 +00:00
Michael Bayne cc961d14e2 Consolidated some duplicated update-related code in DepotMarshaller, nixed some
unneeded type parameterization.
2009-05-29 21:00:33 +00:00
Michael Bayne 04d7fedb92 Boop boop. Final methods with Comparable<?> nixed. The javadocs for
DepotRepository are looking positively svelt and comprehensible.
2009-05-29 19:12:44 +00:00
Michael Bayne 2b847056bf More strictness. Have to use a key to load individual records. Again this is
just as succinct, but type safer:

load(FooRecord.class, fooId) vs load(FooRecord.getKey(fooId))
2009-05-29 18:36:25 +00:00
Michael Bayne f052bba59d Nix obsolete cache documentation. The enum is pretty self documenting. 2009-05-29 00:13:07 +00:00