|
9 | 9 | import java.util.EnumSet;
|
10 | 10 | import java.util.Map;
|
11 | 11 |
|
| 12 | +import org.hibernate.SessionFactory; |
12 | 13 | import org.hibernate.boot.spi.MetadataImplementor;
|
13 | 14 | import org.hibernate.cfg.MappingSettings;
|
14 | 15 | import org.hibernate.engine.config.spi.ConfigurationService;
|
@@ -69,6 +70,24 @@ public ExceptionHandler getExceptionHandler() {
|
69 | 70 | .doValidation( domainModelScope.getDomainModel(), executionOptions, ContributableMatcher.ALL );
|
70 | 71 | }
|
71 | 72 |
|
| 73 | + @Test |
| 74 | + void testRuntimeUsage(DomainModelScope domainModelScope) { |
| 75 | + try (SessionFactory sessionFactory = domainModelScope.getDomainModel().buildSessionFactory()) { |
| 76 | + sessionFactory.inTransaction( (session) -> { |
| 77 | + session.persist( new Client( 1, "stuff", true ) ); |
| 78 | + } ); |
| 79 | + sessionFactory.inTransaction( (session) -> { |
| 80 | + session.find( Client.class, 1 ); |
| 81 | + } ); |
| 82 | + sessionFactory.inTransaction( (session) -> { |
| 83 | + session.createQuery( "from Client", Client.class ).list(); |
| 84 | + } ); |
| 85 | + sessionFactory.inTransaction( (session) -> { |
| 86 | + session.createNativeQuery( "select * from Client", Client.class ).list(); |
| 87 | + } ); |
| 88 | + } |
| 89 | + } |
| 90 | + |
72 | 91 | @BeforeEach
|
73 | 92 | public void setUp(ServiceRegistryScope registryScope, DomainModelScope domainModelScope) {
|
74 | 93 | final MetadataImplementor domainModel = domainModelScope.getDomainModel();
|
@@ -148,6 +167,15 @@ public static class Client {
|
148 | 167 | private Integer id;
|
149 | 168 | private String name;
|
150 | 169 | private boolean active;
|
| 170 | + |
| 171 | + public Client() { |
| 172 | + } |
| 173 | + |
| 174 | + public Client(Integer id, String name, boolean active) { |
| 175 | + this.id = id; |
| 176 | + this.name = name; |
| 177 | + this.active = active; |
| 178 | + } |
151 | 179 | }
|
152 | 180 |
|
153 | 181 | }
|
0 commit comments