@Override public String getMessage() { String message = super.getMessage(); if (origin != null) { message += " : origin(" + origin.getName() + ")"; } return message; }
@Override public void remove(Object entity) { checkOpen(); try { delete( entity ); } catch (MappingException e) { throw exceptionConverter.convert( new IllegalArgumentException( e.getMessage(), e ) ); } catch ( RuntimeException e ) { //including HibernateException throw exceptionConverter.convert( e ); } }
/** * Locate the persister by class or entity name, requiring that such a persister * exist. * * @param name The class or entity name * * @return The defined persister for this entity * * @throws SemanticException Indicates the persister could not be found */ public EntityPersister requireClassPersister(String name) throws SemanticException { EntityPersister cp; try { cp = findEntityPersisterByName( name ); if ( cp == null ) { throw new QuerySyntaxException( name + " is not mapped" ); } } catch ( MappingException e ) { throw new DetailedSemanticException( e.getMessage(), e ); } return cp; }
private void firePersist(Map copiedAlready, PersistEvent event) { checkTransactionSynchStatus(); try { for ( PersistEventListener listener : listeners( EventType.PERSIST ) ) { listener.onPersist( event, copiedAlready ); } } catch ( MappingException e ) { throw exceptionConverter.convert( new IllegalArgumentException( e.getMessage() ) ) ; } catch ( RuntimeException e ) { throw exceptionConverter.convert( e ); } finally { delayedAfterCompletion(); } }
private void fireMerge(Map copiedAlready, MergeEvent event) { try { checkTransactionSynchStatus(); for ( MergeEventListener listener : listeners( EventType.MERGE ) ) { listener.onMerge( event, copiedAlready ); } } catch ( ObjectDeletedException sse ) { throw exceptionConverter.convert( new IllegalArgumentException( sse ) ); } catch ( MappingException e ) { throw exceptionConverter.convert( new IllegalArgumentException( e.getMessage(), e ) ); } catch ( RuntimeException e ) { //including HibernateException throw exceptionConverter.convert( e ); } finally { delayedAfterCompletion(); } }
private void fireDelete(DeleteEvent event) { try{ checkTransactionSynchStatus(); for ( DeleteEventListener listener : listeners( EventType.DELETE ) ) { listener.onDelete( event ); } } catch ( ObjectDeletedException sse ) { throw exceptionConverter.convert( new IllegalArgumentException( sse ) ); } catch ( MappingException e ) { throw exceptionConverter.convert( new IllegalArgumentException( e.getMessage(), e ) ); } catch ( RuntimeException e ) { //including HibernateException throw exceptionConverter.convert( e ); } finally { delayedAfterCompletion(); } }
private void fireDelete(DeleteEvent event, Set transientEntities) { try{ checkTransactionSynchStatus(); for ( DeleteEventListener listener : listeners( EventType.DELETE ) ) { listener.onDelete( event, transientEntities ); } } catch ( ObjectDeletedException sse ) { throw exceptionConverter.convert( new IllegalArgumentException( sse ) ); } catch ( MappingException e ) { throw exceptionConverter.convert( new IllegalArgumentException( e.getMessage(), e ) ); } catch ( RuntimeException e ) { //including HibernateException throw exceptionConverter.convert( e ); } finally { delayedAfterCompletion(); } }
private Object fireMerge(MergeEvent event) { try { checkTransactionSynchStatus(); checkNoUnresolvedActionsBeforeOperation(); for ( MergeEventListener listener : listeners( EventType.MERGE ) ) { listener.onMerge( event ); } checkNoUnresolvedActionsAfterOperation(); } catch ( ObjectDeletedException sse ) { throw exceptionConverter.convert( new IllegalArgumentException( sse ) ); } catch ( MappingException e ) { throw exceptionConverter.convert( new IllegalArgumentException( e.getMessage(), e ) ); } catch ( RuntimeException e ) { //including HibernateException throw exceptionConverter.convert( e ); } return event.getResult(); }
@Override protected void buildSessionFactory() { try { super.buildSessionFactory(); fail("Should have thrown MappingException!"); } catch (MappingException e) { assertEquals("The INSERT statement for table [Competition] contains no column, and this is not supported by [org.hibernate.dialect.HANAColumnStoreDialect]", e.getMessage()); } }
@Override protected void buildResources() { try { super.buildResources(); fail( "Should throw exception!" ); } catch (MappingException expected) { assertEquals( "You cannot override the [uid] non-identifier property from the [org.hibernate.test.annotations.override.mappedsuperclass.MappedSuperClassWithUuidAsBasic] base class or @MappedSuperclass and make it an identifier in the [org.hibernate.test.annotations.override.mappedsuperclass.SubclassWithUuidAsId] subclass!", expected.getMessage() ); } }
private void firePersist(PersistEvent event) { try { checkTransactionSynchStatus(); checkNoUnresolvedActionsBeforeOperation(); for ( PersistEventListener listener : listeners( EventType.PERSIST ) ) { listener.onPersist( event ); } } catch (MappingException e) { throw exceptionConverter.convert( new IllegalArgumentException( e.getMessage() ) ); } catch (RuntimeException e) { throw exceptionConverter.convert( e ); } finally { try { checkNoUnresolvedActionsAfterOperation(); } catch (RuntimeException e) { throw exceptionConverter.convert( e ); } } }
public void testAuditedDynamicComponentFailure() throws URISyntaxException { final Configuration config = new Configuration(); final URL hbm = Thread.currentThread().getContextClassLoader().getResource( "mappings/dynamicComponents/mapAudited.hbm.xml" ); config.addFile( new File( hbm.toURI() ) ); final String auditStrategy = getAuditStrategy(); if ( !StringTools.isEmpty( auditStrategy ) ) { config.setProperty( EnversSettings.AUDIT_STRATEGY, auditStrategy ); } final ServiceRegistry serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( config.getProperties() ); try { config.buildSessionFactory( serviceRegistry ); Assert.fail( "MappingException expected" ); } catch ( MappingException e ) { Assert.assertEquals( "Audited dynamic-component properties are not supported. Consider applying @NotAudited annotation to " + AuditedDynamicComponentEntity.class.getName() + "#customFields.", e.getMessage() ); } finally { ServiceRegistryBuilder.destroy( serviceRegistry ); } }
@Test public void testLegacyCriteriaJpavsHibernateEntityName() { doInJPA( this::entityManagerFactory, entityManager -> { Event event1 = new Event(); event1.id = 1L; event1.name = "E1"; entityManager.persist( event1 ); Event event2 = new Event(); event2.id = 2L; event2.name = "E2"; entityManager.persist( event2 ); List<String> eventNames = entityManager.unwrap( Session.class ) .createQuery( "select ae.name from ApplicationEvent ae" ) .list(); try { List<Event> events = entityManager.unwrap( Session.class ) .createCriteria( "ApplicationEvent" ) .list(); } catch ( MappingException expected ) { assertEquals( "Unknown entity: ApplicationEvent", expected.getMessage() ); } List<Event> events = entityManager.unwrap( Session.class ) .createCriteria( Event.class.getName() ) .list(); }); }
throw new RecoverableException( e.getMessage(), e );
throw new IllegalArgumentException( e.getMessage(), e );
throw exceptionConverter.convert( new IllegalArgumentException( e.getMessage(), e ) );
throw new IllegalArgumentException( e.getMessage(), e );
@Override public String getMessage() { String message = super.getMessage(); if (origin != null) { message += " : origin(" + origin.getName() + ")"; } return message; }
public void remove(Object entity) { checkTransactionNeeded(); try { getSession().delete( entity ); } catch ( MappingException e ) { throw new IllegalArgumentException( e.getMessage(), e ); } catch ( RuntimeException e ) { //including HibernateException throw convert( e ); } }
public void persist(Object entity) { checkTransactionNeeded(); try { getSession().persist( entity ); } catch ( MappingException e ) { throw new IllegalArgumentException( e.getMessage() ); } catch ( RuntimeException e ) { throw convert( e ); } }