I am attempting to save unique reference data within a mysql database. This data does not change over time, but can be added to. Is there an intelligent way of doing this in hibernate?
Currently the test is to create the pojo, query by example, if it exists use that object, otherwise save it. This seems tedious especially if there's a large list of reference objects, some that exist and some that don't in the database.
Any ideas?
Thanks,
w
PS. A concrete example of one of the tables. A large table with URLs and ids referenced by a number of different tables. When a new object is persisted that references the URL it may or may not already be there, if it is it should reference the existing, if not it should create a new one.
|