File tree Expand file tree Collapse file tree 4 files changed +70
-0
lines changed
java/org/hibernate/orm/test/jpa/boot
resources/org/hibernate/orm/test/jpa/boot/META-INF Expand file tree Collapse file tree 4 files changed +70
-0
lines changed Original file line number Diff line number Diff line change 1111import java .util .HashMap ;
1212import java .util .List ;
1313import java .util .Map ;
14+
1415import jakarta .persistence .EntityManagerFactory ;
1516import jakarta .persistence .Persistence ;
1617
18+ import org .hibernate .HibernateException ;
1719import org .hibernate .cfg .AvailableSettings ;
1820import org .hibernate .service .spi .ServiceException ;
1921
2022import org .hibernate .testing .boot .ClassLoaderServiceTestingImpl ;
2123import org .junit .jupiter .api .Assertions ;
2224import org .junit .jupiter .api .Test ;
2325
26+ import static org .junit .jupiter .api .Assertions .fail ;
27+
2428/**
2529 * Test to verify that a dump configuration error results in an exception being
2630 * thrown even when booting via the standard JPA boostrap API.
@@ -42,6 +46,17 @@ public void exceptionOnIllegalPUWithoutProviderTest() {
4246 bootstrapPersistenceUnit ( "IntentionallyBrokenWihoutExplicitProvider" ) );
4347 }
4448
49+ @ Test
50+ public void missingClassPUTest () {
51+ try {
52+ bootstrapPersistenceUnit ( "IntentionallyMissingClass" );
53+ fail ("A HibernateException due to a missing class in the persistence.xml should have been thrown" );
54+ }
55+ catch (HibernateException e ) {
56+ // Success
57+ }
58+ }
59+
4560 private void bootstrapPersistenceUnit (final String puName ) {
4661 final Map <String , Object > properties = new HashMap <>();
4762 properties .put ( AvailableSettings .CLASSLOADERS , Arrays .asList ( new TestClassLoader () ) );
Original file line number Diff line number Diff line change 1+ /*
2+ * SPDX-License-Identifier: Apache-2.0
3+ * Copyright Red Hat Inc. and Hibernate Authors
4+ */
5+ package org .hibernate .orm .test .jpa .boot ;
6+
7+
8+ import jakarta .persistence .Entity ;
9+ import jakarta .persistence .Id ;
10+ import jakarta .persistence .OneToOne ;
11+
12+ /**
13+ * @author Jan Schatteman
14+ */
15+ @ Entity (name = "Event" )
16+ public class Event {
17+ @ Id
18+ @ OneToOne
19+ private EventId id ;
20+
21+ public EventId getId () {
22+ return id ;
23+ }
24+
25+ public void setId (EventId id ) {
26+ this .id = id ;
27+ }
28+ }
Original file line number Diff line number Diff line change 1+ /*
2+ * SPDX-License-Identifier: Apache-2.0
3+ * Copyright Red Hat Inc. and Hibernate Authors
4+ */
5+ package org .hibernate .orm .test .jpa .boot ;
6+
7+
8+ import jakarta .persistence .Entity ;
9+ import jakarta .persistence .GeneratedValue ;
10+ import jakarta .persistence .Id ;
11+
12+ /**
13+ * @author Jan Schatteman
14+ */
15+ @ Entity (name = "EventId" )
16+ public class EventId {
17+
18+ @ Id
19+ @ GeneratedValue
20+ private Long id ;
21+
22+ }
Original file line number Diff line number Diff line change 2525 </properties >
2626 </persistence-unit >
2727
28+ <persistence-unit name =" IntentionallyMissingClass" >
29+ <provider >org.hibernate.jpa.HibernatePersistenceProvider</provider >
30+ <class >org.hibernate.orm.test.jpa.boot.Event</class >
31+ </persistence-unit >
32+
2833</persistence >
You can’t perform that action at this time.
0 commit comments