Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SchemaManager #399

Closed
gavinking opened this issue Apr 18, 2023 · 3 comments · Fixed by #431
Closed

SchemaManager #399

gavinking opened this issue Apr 18, 2023 · 3 comments · Fixed by #431

Comments

@gavinking
Copy link
Contributor

For testing, it's quite useful to have a programmatic way to perform schema management, instead of messing about with properties and creating/destroying the EntityManagerFactory.

@gavinking
Copy link
Contributor Author

As possible starting point for discussion, here's an API we recently added to Hibernate:

public interface SchemaManager {
	/**
	 * Export database objects mapped by Hibernate entities.
	 *
	 * @param createSchemas if {@code true}, attempt to create schemas,
	 *                      otherwise, assume the schemas already exist
	 */
	void exportMappedObjects(boolean createSchemas);

	/**
	 * Drop database objects mapped by Hibernate entities, undoing the
	 * {@linkplain #exportMappedObjects(boolean) previous export}.
	 * <p>
	 * @param dropSchemas if {@code true}, drop schemas,
	 *                    otherwise, leave them be
	 */
	void dropMappedObjects(boolean dropSchemas);

	/**
	 * Validate that the database objects mapped by Hibernate entities
	 * have the expected definitions.
	 */
	void validateMappedObjects();

	/**
	 * Truncate the database tables mapped by Hibernate entities, and
	 * then re-import initial data from any configured
	 * {@linkplain org.hibernate.cfg.AvailableSettings#JAKARTA_HBM2DDL_LOAD_SCRIPT_SOURCE
	 * load script}.
	 */
	void truncateMappedObjects();
}

Of course, validateMappedObjects() and truncateMappedObjects() might not be features you folks want in the JPA spec, since JPA doesn't have any such functionality defined today.

gavinking added a commit to gavinking/persistence that referenced this issue Aug 8, 2023
@gavinking
Copy link
Contributor Author

Folks, please review #431

@gavinking
Copy link
Contributor Author

If we decide to do this, and if SchemaManager has a validate() method, then I think we should also list "validate" as one of the allowed values for schema export config. It would have fairly weakly-defined semantics (and providers could even just ignore it) but even so it's worth enumerating I believe.

(Note that validate is a lot less problematic than update, so I'm not really contradicting myself here.)

gavinking added a commit to gavinking/persistence that referenced this issue Aug 10, 2023
gavinking added a commit to gavinking/persistence that referenced this issue Aug 10, 2023
gavinking added a commit to gavinking/persistence that referenced this issue Aug 10, 2023
gavinking added a commit to gavinking/persistence that referenced this issue Aug 10, 2023
gavinking added a commit to gavinking/persistence that referenced this issue Aug 10, 2023
gavinking added a commit to gavinking/persistence that referenced this issue Aug 10, 2023
@gavinking gavinking linked a pull request Aug 11, 2023 that will close this issue
gavinking added a commit to gavinking/persistence that referenced this issue Aug 11, 2023
gavinking added a commit to gavinking/persistence that referenced this issue Aug 11, 2023
gavinking added a commit to gavinking/persistence that referenced this issue Aug 11, 2023
gavinking added a commit to gavinking/persistence that referenced this issue Aug 11, 2023
gavinking added a commit to gavinking/persistence that referenced this issue Aug 11, 2023
gavinking added a commit to gavinking/persistence that referenced this issue Aug 11, 2023
gavinking added a commit to gavinking/persistence that referenced this issue Aug 11, 2023
gavinking added a commit to gavinking/persistence that referenced this issue Aug 11, 2023
gavinking added a commit to gavinking/persistence that referenced this issue Aug 21, 2023
gavinking added a commit to gavinking/persistence that referenced this issue Aug 21, 2023
gavinking added a commit to gavinking/persistence that referenced this issue Aug 21, 2023
gavinking added a commit to gavinking/persistence that referenced this issue Aug 21, 2023
gavinking added a commit to gavinking/persistence that referenced this issue Aug 21, 2023
gavinking added a commit to gavinking/persistence that referenced this issue Aug 21, 2023
lukasj pushed a commit that referenced this issue Aug 21, 2023
lukasj pushed a commit that referenced this issue Aug 21, 2023
gavinking added a commit to gavinking/persistence that referenced this issue Aug 21, 2023
lukasj pushed a commit that referenced this issue Aug 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant