Commit Graph

310 Commits

Author SHA1 Message Date
Michael Bayne 566ebcf7f9 Only release the connection if we didn't report it as failed. 2008-11-17 21:55:02 +00:00
Michael Bayne 42aa622551 Added README and build target descriptions. 2008-11-17 19:10:33 +00:00
Michael Bayne ceafda9f83 We need google-collect.jar. 2008-11-17 18:47:46 +00:00
Michael Bayne 76aa7f2cef Tell Eclipse about our dependency on samskivert. 2008-11-17 18:43:30 +00:00
Michael Bayne bc30c2061c Some Eclipse bits. 2008-11-17 18:41:06 +00:00
Michael Bayne 1f86dbd9c4 Google Collectivised. 2008-11-16 18:31:25 +00:00
Michael Bayne 0fc1d68bbe Fixed up svn:keywords property. 2008-11-16 08:03:33 +00:00
Michael Bayne 9c0dbb5b47 Fixed up packages. 2008-11-16 08:01:19 +00:00
Michael Bayne c60181a484 We need a GWT module. 2008-11-16 07:53:22 +00:00
Michael Bayne 50053f5282 Oh boy, we have to build a GWT source jar file. 2008-11-16 07:34:30 +00:00
Michael Bayne 7a23a6bd49 Copy the tests over. I couldn't migrate these with the rest of the SVN
migration because svndumpfilter is a royal pain in my ass.
2008-11-16 07:30:20 +00:00
Michael Bayne 711fd44911 No longer needed. 2008-11-16 06:55:13 +00:00
Michael Bayne 601a15c00f Added snapshot target. 2008-11-16 06:49:09 +00:00
Michael Bayne b32b4eecc3 Updated the source headers and added the license file. 2008-11-16 06:17:45 +00:00
Michael Bayne b9604c2d56 Ignore the jar dependencies we keep in here. 2008-11-16 06:09:33 +00:00
Michael Bayne 40c1480039 More tidying, added Javadoc overview. 2008-11-16 06:08:56 +00:00
Michael Bayne 745c380e8d Repackage Depot as com.samskivert.depot as it is now a standalone library.
We're also going to allow ourselves the luxury of a Google Collections
dependency.
2008-11-16 05:59:28 +00:00
Michael Bayne 6959383b6c Unified Query and Modifier under Operation which cleans up some niggles in
PersistenceContext.
2008-11-13 23:35:12 +00:00
Par Winzell f653e59a66 That was broken code-in-progress and not meant to be commnitted. 2008-11-05 00:19:59 +00:00
Par Winzell 49391b1995 When we reinitialize the Throttle with a smaller number of allowed operations within a time period, we should preserve the oldest rather than the newest ones, or we'll most likely be in immediate and unfair violation of the limit. 2008-11-05 00:18:21 +00:00
Par Winzell bac0348951 Change these hard-coded defaults. Should also be made configurable. 2008-11-04 19:20:33 +00:00
Michael Bayne 05f499736e Nixed unused import, commented out others that go with commented out code. 2008-11-01 05:39:27 +00:00
Michael Bayne 8ec25c5a6d Make the 1.5 compiler happy. 2008-10-31 00:42:53 +00:00
Michael Bayne 2b8bc0c97f When we can switch entirely to 1.6 we can use Postgres's value = any(?::int[])
form to pass as many damned keys we want in a giant array. At that time we can
nix all the >32,768 key fiddly business.
2008-10-31 00:17:36 +00:00
Michael Bayne ec76d4d29f Oops, avoid introducing a bug when nulls == zeros == values.length. We want to
return null in that case.
2008-10-24 05:18:50 +00:00
Michael Bayne 2309c490f7 Compromise on our 0 == null stance for primary key columns. See the code
comments for further details.
2008-10-24 05:13:28 +00:00
Michael Bayne ba97743754 Make sure we use the up to date metadata when doing our stale column check. 2008-10-22 01:09:22 +00:00
Michael Bayne 19287550f4 More javadoc cleanup. 2008-09-30 00:23:57 +00:00
Michael Bayne 4c94296b67 Javadoc fixes. 2008-09-30 00:12:08 +00:00
Michael Bayne fee6be6c2d 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.
2008-09-25 23:40:01 +00:00
Michael Bayne 2b21105dc1 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.
2008-09-25 22:27:58 +00:00
Michael Bayne 2c9c9b47c1 Let's preserve the ability for callers with uncomplicated needs to create and
initialize a persistence context in one fell swoop.
2008-09-24 19:09:17 +00:00
Michael Bayne 0e68c8a599 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().
2008-09-24 18:33:25 +00:00
Michael Bayne 81c25ae4f1 Properly handle int[] fields when encountered as unassociated values. We
already do the right thing when we process them as fields of persistent
records.
2008-09-23 17:18:23 +00:00
Michael Bayne f33a376f7e Formatting tweaks. 2008-09-23 17:17:05 +00:00
Michael Bayne d7f864dfe4 Don't try to manage the cache manager. Push that burden out to the caller who
may have their own needs and arrangements.
2008-09-20 03:30:49 +00:00
Michael Bayne 3e8ac68af6 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.
2008-09-17 19:09:08 +00:00
Michael Bayne 5ac15a99ca Use varying size blobs for int[] columns like we do byte[]. 2008-09-16 22:51:59 +00:00
Michael Bayne b64658fd83 Handle conversion from int[] to byte[] manually rather than relying on the JDBC
driver to know how to do it.
2008-09-16 22:49:11 +00:00
Michael Bayne 9112b3c7e2 Javadoc fix from Dave. 2008-09-16 21:54:21 +00:00
Michael Bayne 84dd3c6b5f 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.
2008-09-16 21:33:22 +00:00
Michael Bayne e25aa25bd6 Nixed unused imports. 2008-09-16 02:01:19 +00:00
Michael Bayne 2b1b2e8334 Missed a spot. 2008-09-15 18:46:48 +00:00
Michael Bayne 759fb587dc Name things a bit more clearly to indicate that we're manipulating field
definitions, not necessarily field overrides.
2008-09-15 18:42:12 +00:00
Michael Bayne a507308c2b Zell reminds me that I want to use FieldDefinition rather than FieldOverride
which is meant to be used only in certain circumstances.
2008-09-15 18:37:04 +00:00
Michael Bayne 7e8c7fadcb 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.
2008-09-15 18:33:21 +00:00
Michael Bayne 2f57697c32 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.
2008-09-15 18:22:18 +00:00
Michael Bayne 98ac644ad9 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.
2008-09-12 01:55:54 +00:00
Michael Bayne 2611a1076b Let's have a stack trace here because these mismatches are just plain bizarre. 2008-09-12 01:49:06 +00:00
Michael Bayne d47e85fe9f 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.
2008-09-12 00:24:14 +00:00