Skip to content

Commit 076ee5f

Browse files
committed
HHH-10104 - Add Test
1 parent 5f67ac3 commit 076ee5f

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Hibernate, Relational Persistence for Idiomatic Java
3+
*
4+
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
5+
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
6+
*/
7+
package org.hibernate.jpa.test.schemagen;
8+
9+
import javax.persistence.Entity;
10+
import javax.persistence.GeneratedValue;
11+
import javax.persistence.Id;
12+
13+
/**
14+
* @author Andrea Boriero
15+
*/
16+
@Entity
17+
public class Document {
18+
@Id
19+
@GeneratedValue
20+
private Long id;
21+
private String name;
22+
23+
public Document() {
24+
}
25+
26+
public Document(String name) {
27+
this.name = name;
28+
}
29+
30+
public Long getId() {
31+
return id;
32+
}
33+
34+
public String getName() {
35+
return name;
36+
}
37+
38+
public void setName(String name) {
39+
this.name = name;
40+
}
41+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Hibernate, Relational Persistence for Idiomatic Java
3+
*
4+
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
5+
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
6+
*/
7+
package org.hibernate.jpa.test.schemagen;
8+
9+
import javax.persistence.EntityManager;
10+
import javax.persistence.EntityTransaction;
11+
import javax.persistence.TypedQuery;
12+
import java.util.List;
13+
14+
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
15+
16+
import org.junit.Before;
17+
import org.junit.Test;
18+
19+
import org.hibernate.testing.TestForIssue;
20+
21+
import static org.hamcrest.core.Is.is;
22+
import static org.junit.Assert.assertThat;
23+
24+
/**
25+
* @author Andrea Boriero
26+
*/
27+
@TestForIssue(jiraKey = "HHH-10104")
28+
public class SchemaCreateDropTest extends BaseEntityManagerFunctionalTestCase {
29+
30+
private EntityManager em;
31+
32+
@Override
33+
public Class[] getAnnotatedClasses() {
34+
return new Class[] {Document.class};
35+
}
36+
37+
@Before
38+
public void setUp() {
39+
em = getOrCreateEntityManager();
40+
EntityTransaction tx = em.getTransaction();
41+
tx.begin();
42+
em.persist( new Document( "hibernate" ) );
43+
tx.commit();
44+
}
45+
46+
@Test
47+
public void testQueryWithoutTransaction() {
48+
TypedQuery<String> query = em.createQuery( "SELECT d.name FROM Document d", String.class );
49+
List<String> results = query.getResultList();
50+
assertThat( results.size(), is( 1 ) );
51+
}
52+
53+
}

0 commit comments

Comments
 (0)