SchemaManager.validation() should throw SchemaValidationException
Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
parent
5caa0b2735
commit
bf6a66d9ce
|
@ -11,6 +11,7 @@ import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.relational.SchemaManager;
|
import org.hibernate.relational.SchemaManager;
|
||||||
import org.hibernate.tool.schema.Action;
|
import org.hibernate.tool.schema.Action;
|
||||||
|
import org.hibernate.tool.schema.spi.SchemaManagementException;
|
||||||
import org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator;
|
import org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -92,7 +93,12 @@ public class SchemaManagerImpl implements SchemaManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validate() throws SchemaValidationException {
|
public void validate() throws SchemaValidationException {
|
||||||
validateMappedObjects();
|
try {
|
||||||
|
validateMappedObjects();
|
||||||
|
}
|
||||||
|
catch ( SchemaManagementException sme ) {
|
||||||
|
throw new SchemaValidationException( sme.getMessage(), sme );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -10,6 +10,7 @@ import jakarta.persistence.CascadeType;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
import jakarta.persistence.ManyToOne;
|
import jakarta.persistence.ManyToOne;
|
||||||
|
import jakarta.persistence.SchemaValidationException;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.engine.spi.SessionImplementor;
|
import org.hibernate.engine.spi.SessionImplementor;
|
||||||
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
|
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
|
||||||
|
@ -59,6 +60,13 @@ public class SchemaManagerDefaultSchemaTest {
|
||||||
catch (SchemaManagementException e) {
|
catch (SchemaManagementException e) {
|
||||||
assertTrue( e.getMessage().contains("ForTesting") );
|
assertTrue( e.getMessage().contains("ForTesting") );
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
factory.getSchemaManager().validate();
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
catch (SchemaValidationException e) {
|
||||||
|
assertTrue( e.getMessage().contains("ForTesting") );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity(name="BookForTesting")
|
@Entity(name="BookForTesting")
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.orm.test.schemamanager;
|
package org.hibernate.orm.test.schemamanager;
|
||||||
|
|
||||||
|
import jakarta.persistence.SchemaValidationException;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.engine.spi.SessionImplementor;
|
import org.hibernate.engine.spi.SessionImplementor;
|
||||||
import org.hibernate.tool.schema.spi.SchemaManagementException;
|
import org.hibernate.tool.schema.spi.SchemaManagementException;
|
||||||
|
@ -65,6 +66,13 @@ public class SchemaManagerExplicitSchemaTest {
|
||||||
catch (SchemaManagementException e) {
|
catch (SchemaManagementException e) {
|
||||||
assertTrue( e.getMessage().contains("ForTesting") );
|
assertTrue( e.getMessage().contains("ForTesting") );
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
factory.getSchemaManager().validate();
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
catch (SchemaValidationException e) {
|
||||||
|
assertTrue( e.getMessage().contains("ForTesting") );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity(name="BookForTesting")
|
@Entity(name="BookForTesting")
|
||||||
|
|
Loading…
Reference in New Issue