Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Enforcing schema versioning

Hi,

Well, I've been quite successfully using Liquibase for that (there are a lot of other similar tools).

The way I'm integrating it with Java EE (and thus JPA/Eclipselink) is by having a @Singleton @Startup EJB with a @PostConstruct and an injected @Resource that gets the same data source as Eclipselink. I then just fire Liquibase programmatically, which checks/runs a lot of "changelogs" (xml).

Newer version of liquibase support something like that automatically using CDI, but I didn't integrate this yet.

Some could argue that you would actually need another connection for that, to make sure that EclipseLink can't change the schema itself.

Best regarsd,

Yannick Majoros

Le 07-11-14 11:03, David North a écrit :
Hi,

I'm trying to solve a classic problem in my EclipseLink-based product.
When the product starts up, it needs to reassure itself that the
database is in the shape it expects.

The usual way we've done this in the past is to have a "metadata" table
in the database which contains a bucket of key-value pairs, e.g.
version=1. We can then increment the version number as we add/alter
tables, and the code can check this to ensure it's not running on a
database at the wrong version.

The difficulty I'm having is finding a nice way to do this in
EclipseLink. At the moment, we're using a SessionEventListener to
execute the check in postLogin, however this feels more difficult/messy
than it should be. How do other users solve this problem? Is there a
different approach that feels more natural in EclipseLink?

Thanks,
David
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/eclipselink-users



Back to the top