File tree Expand file tree Collapse file tree 6 files changed +407
-0
lines changed
hibernate-core/src/test/java/org/hibernate/orm/test/mapping/inheritance/discriminator Expand file tree Collapse file tree 6 files changed +407
-0
lines changed Original file line number Diff line number Diff line change 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+
8+ //$Id: Bid.java 5733 2005-02-14 15:56:06Z oneovthafew $
9+ package org .hibernate .orm .test .mapping .inheritance .discriminator ;
10+
11+ import java .math .BigDecimal ;
12+
13+ /**
14+ * @author Jan Schatteman
15+ */
16+ public abstract class AbstractAccount {
17+ private Long id ;
18+ private AccountOwner owner ;
19+ private BigDecimal amount ;
20+
21+ public Long getId () {
22+ return id ;
23+ }
24+
25+ public void setId (Long id ) {
26+ this .id = id ;
27+ }
28+
29+ public BigDecimal getAmount () {
30+ return amount ;
31+ }
32+
33+ public void setAmount (BigDecimal amount ) {
34+ this .amount = amount ;
35+ }
36+
37+ public AccountOwner getOwner () {
38+ return owner ;
39+ }
40+
41+ public void setOwner (AccountOwner owner ) {
42+ this .owner = owner ;
43+ }
44+ }
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" ?>
2+ <!--
3+ ~ Hibernate, Relational Persistence for Idiomatic Java
4+ ~
5+ ~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
6+ ~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
7+ -->
8+ <!DOCTYPE hibernate-mapping PUBLIC
9+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
10+ "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
11+
12+ <hibernate-mapping
13+ package =" org.hibernate.orm.test.mapping.inheritance.discriminator" >
14+
15+ <class name =" AccountOwner" table =" AccOwner" >
16+ <id name =" id" >
17+ <generator class =" native" />
18+ </id >
19+ <property name =" description" />
20+
21+ <set name =" creditAccounts"
22+ cascade =" persist" >
23+ <key column =" ownerId" />
24+ <one-to-many class =" CreditAccount" />
25+ </set >
26+
27+ <set name =" debitAccounts"
28+ cascade =" persist" >
29+ <key column =" ownerId" />
30+ <one-to-many class =" DebitAccount" />
31+ </set >
32+ </class >
33+
34+ <class name =" AbstractAccount" table =" Accounts" abstract =" true" dynamic-update =" true" >
35+ <id name =" id" >
36+ <generator class =" native" />
37+ </id >
38+
39+ <discriminator column =" DISC" insert =" true" type =" java.lang.String" not-null =" true" />
40+
41+ <property name =" amount"
42+ scale =" 19"
43+ precision =" 31" />
44+
45+ <many-to-one name =" owner"
46+ column =" ownerId"
47+ cascade =" persist" />
48+
49+ <subclass name =" CreditAccount" discriminator-value =" C" dynamic-insert =" true" dynamic-update =" true" />
50+
51+ <subclass name =" DebitAccount" discriminator-value =" D" dynamic-insert =" true" dynamic-update =" true" />
52+ </class >
53+
54+ </hibernate-mapping >
Original file line number Diff line number Diff line change 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+
8+ //$Id: Auction.java 5733 2005-02-14 15:56:06Z oneovthafew $
9+ package org .hibernate .orm .test .mapping .inheritance .discriminator ;
10+
11+ import java .util .HashSet ;
12+ import java .util .Set ;
13+
14+ /**
15+ * @author Jan Schatteman
16+ */
17+ public class AccountOwner {
18+ private Long id ;
19+ private String description ;
20+ private Set <AbstractAccount > creditAccounts = new HashSet <>();
21+ private Set <AbstractAccount > debitAccounts = new HashSet <>();
22+
23+ public String getDescription () {
24+ return description ;
25+ }
26+
27+ public void setDescription (String description ) {
28+ this .description = description ;
29+ }
30+
31+ public Long getId () {
32+ return id ;
33+ }
34+
35+ public void setId (Long id ) {
36+ this .id = id ;
37+ }
38+
39+ public Set <AbstractAccount > getCreditAccounts () {
40+ return creditAccounts ;
41+ }
42+
43+ public void setCreditAccounts (Set <AbstractAccount > creditAccounts ) {
44+ this .creditAccounts = creditAccounts ;
45+ }
46+
47+ public Set <AbstractAccount > getDebitAccounts () {
48+ return debitAccounts ;
49+ }
50+
51+ public void setDebitAccounts (Set <AbstractAccount > debitAccounts ) {
52+ this .debitAccounts = debitAccounts ;
53+ }
54+ }
Original file line number Diff line number Diff line change 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+
8+ //$Id: Bid.java 5733 2005-02-14 15:56:06Z oneovthafew $
9+ package org .hibernate .orm .test .mapping .inheritance .discriminator ;
10+
11+ /**
12+ * @author Jan Schatteman
13+ */
14+ public class CreditAccount extends AbstractAccount {
15+ }
Original file line number Diff line number Diff line change 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+
8+ //$Id: Bid.java 5733 2005-02-14 15:56:06Z oneovthafew $
9+ package org .hibernate .orm .test .mapping .inheritance .discriminator ;
10+
11+ /**
12+ * @author Jan Schatteman
13+ */
14+ public class DebitAccount extends AbstractAccount {
15+ }
You can’t perform that action at this time.
0 commit comments