Commit Graph

2402 Commits

Author SHA1 Message Date
samskivert 67d0140701 (Heavily modified) patch from Dave to allow varargs key/value logging bits to
be supplied to ComplainingListener.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2462 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-10-25 00:52:40 +00:00
samskivert f0d55037d1 Let's not use trim() here and avoid creating an intermediate object.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2461 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-10-24 06:26:56 +00:00
samskivert ddf70fc45f Oops, avoid introducing a bug when nulls == zeros == values.length. We want to
return null in that case.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2460 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-10-24 05:18:50 +00:00
samskivert 84d34803de Compromise on our 0 == null stance for primary key columns. See the code
comments for further details.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2459 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-10-24 05:13:28 +00:00
samskivert eac4608b7a A new StringUtil method (a rare occurance!): trim() which safely handles null.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2458 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-10-23 20:57:56 +00:00
samskivert 327b9581b9 Make sure we use the up to date metadata when doing our stale column check.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2457 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-10-22 01:09:22 +00:00
samskivert 8ac0e012ce New convenience functions from Dave. What are the chances?
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2456 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-10-22 00:55:40 +00:00
samskivert 39c9f7a499 Patch from Charlie to allow a Random object to be passed into many of the
pick methods.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2455 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-10-20 16:07:29 +00:00
samskivert 6d7bfd6d7b Incorporated Jamie's Throttle reinitialization code. Added support for updating
the period as well.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2454 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-10-08 19:35:12 +00:00
samskivert ecf0dd6213 More javadoc cleanup.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2453 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-30 00:23:57 +00:00
samskivert 9d66acc2bd Javadoc fixes.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2452 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-30 00:12:08 +00:00
samskivert 2e93d12396 Allow the default auto-commit settings for a connection to be configured along
with the other JDBC properties.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2451 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-26 00:04:16 +00:00
samskivert 6a2b870cf9 Only disable auto-commit if we appear to need to.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2450 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-25 23:58:46 +00:00
samskivert 480ae9edbe Added support for data migrations, which are run after all schema migrations
have been run and are also coordinated between disparate processes by an
in-database lock system.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2449 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-25 23:40:01 +00:00
samskivert 296495a88f Call EntityMigration SchemaMigration because that's what it's for and I want to
add a new DataMigration mechanism so that people can stop using schema
migrations to do data migration.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2448 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-25 22:27:58 +00:00
samskivert 0bf5b3fbd9 More compactification.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2447 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-24 23:44:10 +00:00
samskivert 50be959ac8 Properly implement CountEntryImpl.equals(). Other formatting cleanup.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2446 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-24 23:30:54 +00:00
samskivert 9837f96396 Let's preserve the ability for callers with uncomplicated needs to create and
initialize a persistence context in one fell swoop.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2445 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-24 19:09:17 +00:00
samskivert 462e92e324 Change the way initialization is handled (a bit). It is now possible to create
a PersistenceContext and give it out to all of your repositories and delay
activating the context until you are ready for everyone to start talking to the
database. In this way you can enforce that no one does any database fooling
around before it's OK.

I also introduced DepotRepository.init() where database fooling around is OK.
The general idea is that you register schema migrations in your constructor and
then if you have data migrations to be done (or initialization that requires
reading things from the database), you do that in init().


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2444 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-24 18:33:25 +00:00
samskivert 0950cb02cd Test updates.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2443 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-23 17:18:44 +00:00
samskivert 4c23586e3e Properly handle int[] fields when encountered as unassociated values. We
already do the right thing when we process them as fields of persistent
records.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2442 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-23 17:18:23 +00:00
samskivert 3fba685ca7 Formatting tweaks.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2441 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-23 17:17:05 +00:00
samskivert 52fa489fe5 Put that new method somewhere more sensible.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2440 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-22 16:57:48 +00:00
samskivert 12292b89f2 Patch from Charlie to add magic formatting to the AuditLogger.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2439 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-22 16:47:46 +00:00
samskivert 5248d137fc Don't try to manage the cache manager. Push that burden out to the caller who
may have their own needs and arrangements.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2438 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-20 03:30:49 +00:00
samskivert d1ef556a55 No using raw types. Also no annotating whole methods
@SuppressWarnings("unchecked") even if they're simple.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2437 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-18 17:23:56 +00:00
samskivert 52f5b41f44 Properly handle @GeneratedValue(strategy=GenerationType.IDENTITY,
initialValue=N) for non-zero values of N. This is complicated. Depot used to
"initialize" value generators pretty much every time a table schema was
migrated. For TableValueGenerator it could just NOOP if the proper row was in
the sequence table. IdentityValueGenerator was just broken and ignored any
request to configure an initialValue, so it never did anything.

First I looked into preserving this frequent reinitialization behavior, but it
turns out that it's not possible to read the current value of a sequence in
Postgres without modifying it. So trying to do something like:

SELECT setval('"FooRecord_fooId_seq"', max(currval('"FooRecord_fooId_seq"'),
                                           cast(initialValue as bigint)));

doesn't work because you can't call currval() without first having called
nextval() (and furthermore when you do that, the Postgres client grabs a block
of sequence values for this client so that multiple clients can add rows to a
table without having to coordinate with the server and one another to assign a
new value every time a row is inserted).

So I changed Depot around to not reinitialize value generators unless it really
believes that the column in question is newly added. We can't rely on our own
auto-column creation because it's possible for someone to create a column
through a custom entity migration, so instead we just keep track of what
columns we had before we started all of our migrations (automatic and custom)
and check to see if there are any new columns after all is said and done and if
any of those have value generators, we "create" them.

This allows us to just setval() the sequence to the desired initial value
without first reading it.

This all fails if someone renames a column with a value generator. The column
will appear to Depot to be new and it will try to recreate the value generator
on that column. For TableValueGenerators that will basically NOOP and
everything will be just like it was before. For IdentityValueGenerators,
because of the way that Postgres magically creates a tablename_columnname_seq
sequence for identity value generation, when the column is renamed, the
sequence will retain the old column name and when Depot goes to try to setval()
the sequence based on the new column name, it won't exist and the migration
will fail. So at least we're not silently reinitializing the value generator to
its initial value when a column (with an identity value generator) is renamed.
We also don't try to do anything if the initialValue is not 1 (the default). So
we avoid failing or doing anything wrong if those kinds of columns are renamed.

So we only fail if someone renames a column with an identity value generator
with a non-default initial value. Since one can only put a value generator on a
primary key field and an identity value generator generally means you have
something simple like FooRecord with fooId. This means someone is renaming
their simple auto incrementing primary key field which seems extremely unlikely
because those columns usually have an obvious name that you're never going to
change. No problem!

I also haven't fixed this problem for MySQL yet. I can only handle so much
database befuckaroundery in one go.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2436 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-17 19:09:08 +00:00
andrzej@threerings.net f1a2723292 Added shared true and false predicate instances, with type-safe
accessors (a la Collections.emptyList).


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2435 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-17 01:15:48 +00:00
samskivert 6245c3dd44 Use varying size blobs for int[] columns like we do byte[].
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2434 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-16 22:51:59 +00:00
samskivert ed224ab0cb Handle conversion from int[] to byte[] manually rather than relying on the JDBC
driver to know how to do it.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2433 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-16 22:49:11 +00:00
samskivert 534b224489 Javadoc fix from Dave.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2432 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-16 21:54:21 +00:00
samskivert 129120794a Amazingly, we had apparently never tried to insert a preconfigured row into a
table that had field generators on its primary key. The code just blindly
overwrite the supplied primary key and ran the generators anyway.

We now only run the generators if the record has no primary key. This means we
can't use field generators on non-primary-key fields, but I'm not sure we ever
meant to support that in the first place.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2431 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-16 21:33:22 +00:00
samskivert a5eff55b9f Nixed unused imports.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2430 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-16 02:01:19 +00:00
samskivert f7025032c2 Missed a spot.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2429 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-15 18:46:48 +00:00
samskivert 067e4ebdb6 Name things a bit more clearly to indicate that we're manipulating field
definitions, not necessarily field overrides.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2428 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-15 18:42:12 +00:00
samskivert 58d2b7d2fe Zell reminds me that I want to use FieldDefinition rather than FieldOverride
which is meant to be used only in certain circumstances.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2427 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-15 18:37:04 +00:00
samskivert 9739e50761 Don't log a warning if we don't get a result for every primary key provided
when we're doing a query with primary keys provided by a random caller. We have
know idea where they got those keys or where they have been before we got our
filthy mitts on them.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2426 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-15 18:33:21 +00:00
samskivert bc98a28af8 We're going to allow FieldOverride on @Computed records, just not on @Computed
fields. Maybe Zell will remind me why this was disallowed, but it seems that to
disallow this is to make FieldOverride useless.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2425 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-15 18:22:18 +00:00
samskivert 610b03df80 Ah, entities.keySet() is misleading because it contains records that were found
in the cache as well as records loaded from earlier passes in cases where we
split our query up to avoid database breaking in() clause sizes. Now we track
exactly what we got this time around and report that.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2417 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-12 01:55:54 +00:00
samskivert 63f3e00279 Let's have a stack trace here because these mismatches are just plain bizarre.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2416 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-12 01:49:06 +00:00
samskivert b82bf914d9 If we're going to magically convert ByteEnum to an integer type, then we should
magically assign it a default value of 0 like we do for our other integer types.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2415 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-12 00:24:14 +00:00
samskivert 858560ca69 Nixing the savedoc target.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2414 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-11 08:16:02 +00:00
samskivert 193e2e5853 We're seeing some weirdness here, so let's log the original statement along
with the actual set of wanted and obtained keys when we have a mismatch.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2412 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-10 18:09:23 +00:00
samskivert f4ff354621 Let's log a stack trace on lazy initialization so that we can see who the
culprit is.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2411 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-10 18:01:24 +00:00
samskivert 845f1f47b6 Some invoker jockeying requested by Charlie.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2410 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-10 02:13:57 +00:00
samskivert d45da29c7b Created an explicit EntityMigration.Add for when you want to add a column to a
database and need to provide a defaultValue at the time that you add it, but
don't want to have to define a permanent default value on the field.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2409 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-10 02:00:19 +00:00
samskivert e0d3f6b2c9 Don't try to do the primary key lookup on delete for records that define no
primary key.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2408 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-08 19:01:30 +00:00
samskivert ae552d1696 Cope with the goddamned broken generics implementation in JDK 1.5.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2407 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-08 18:58:12 +00:00
samskivert 155a188da2 We need Key to export a Key.Expression which we can use inside the SQL for a
KeySet so that the "where" keyword is not repeated every time we bind a key.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2406 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-08 17:54:11 +00:00
samskivert 35c90b8926 Beans/frank.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2405 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-09-08 16:48:32 +00:00