-
Notifications
You must be signed in to change notification settings - Fork 3.5k
/
ToOneOnDeleteHbmTest.java
73 lines (58 loc) · 1.84 KB
/
ToOneOnDeleteHbmTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.ondelete.toone.hbm;
import org.hibernate.Session;
import org.hibernate.dialect.SybaseDialect;
import org.hibernate.testing.SkipForDialect;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
/**
* @author Vlad Mihalcea
*/
public class ToOneOnDeleteHbmTest extends BaseCoreFunctionalTestCase {
@Test
@SkipForDialect(
value = SybaseDialect.class,
jiraKey = "HHH-13559",
comment = "on-delete=\"cascade\" is not supported for unidirectional to-one associations using Sybase"
)
public void testManyToOne() throws Exception {
Session session = openSession();
session.getTransaction().begin();
Parent parent = new Parent();
parent.setId( 1L );
session.persist( parent );
Child child1 = new Child();
child1.setId( 1L );
child1.setParent( parent );
session.persist( child1 );
GrandChild grandChild11 = new GrandChild();
grandChild11.setId( 1L );
grandChild11.setParent( child1 );
session.persist( grandChild11 );
Child child2 = new Child();
child2.setId( 2L );
child2.setParent( parent );
session.persist( child2 );
GrandChild grandChild21 = new GrandChild();
grandChild21.setId( 2L );
grandChild21.setParent( child2 );
session.persist( grandChild21 );
session.getTransaction().commit();
session.close();
session = openSession();
session.getTransaction().begin();
parent = session.get( Parent.class, 1L );
session.delete( parent );
session.getTransaction().commit();
session.close();
}
@Override
public String[] getMappings() {
return new String[] { "ondelete/toone/hbm/ToOneOnDelete.hbm.xml" };
}
}