From 0c4439b73187668fa91109df4914d4cd4ad845fc Mon Sep 17 00:00:00 2001 From: Gavin King Date: Sat, 8 Jul 2023 11:33:13 +0200 Subject: [PATCH] copy some test entities from core tests to modelgen tests --- .../jpamodelgen/test/fromcore/Address.java | 104 +++++++++++ .../jpamodelgen/test/fromcore/Alias.java | 99 +++++++++++ .../jpamodelgen/test/fromcore/Article.java | 25 +++ .../test/fromcore/BaseEmbeddedEntity.java | 63 +++++++ .../jpamodelgen/test/fromcore/CoreTest.java | 29 ++++ .../jpamodelgen/test/fromcore/Country.java | 47 +++++ .../jpamodelgen/test/fromcore/CreditCard.java | 129 ++++++++++++++ .../jpamodelgen/test/fromcore/Customer.java | 163 ++++++++++++++++++ .../jpamodelgen/test/fromcore/Entity1.java | 40 +++++ .../jpamodelgen/test/fromcore/Entity2.java | 40 +++++ .../jpamodelgen/test/fromcore/Entity3.java | 39 +++++ .../jpamodelgen/test/fromcore/Info.java | 103 +++++++++++ .../jpamodelgen/test/fromcore/LineItem.java | 77 +++++++++ .../jpamodelgen/test/fromcore/MapEntity.java | 33 ++++ .../test/fromcore/MapEntityLocal.java | 25 +++ .../jpamodelgen/test/fromcore/Order.java | 145 ++++++++++++++++ .../jpamodelgen/test/fromcore/Person.java | 44 +++++ .../jpamodelgen/test/fromcore/PersonId.java | 74 ++++++++ .../jpamodelgen/test/fromcore/Phone.java | 91 ++++++++++ .../jpamodelgen/test/fromcore/Product.java | 142 +++++++++++++++ .../jpamodelgen/test/fromcore/ShelfLife.java | 44 +++++ .../test/fromcore/SomeMappedSuperclass.java | 27 +++ .../SomeMappedSuperclassSubclass.java | 25 +++ .../jpamodelgen/test/fromcore/Spouse.java | 120 +++++++++++++ .../jpamodelgen/test/fromcore/Thing.java | 39 +++++ .../test/fromcore/ThingWithQuantity.java | 25 +++ .../test/fromcore/Translation.java | 23 +++ .../test/fromcore/VersionedEntity.java | 47 +++++ 28 files changed, 1862 insertions(+) create mode 100644 tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Address.java create mode 100644 tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Alias.java create mode 100644 tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Article.java create mode 100644 tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/BaseEmbeddedEntity.java create mode 100644 tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/CoreTest.java create mode 100644 tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Country.java create mode 100644 tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/CreditCard.java create mode 100644 tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Customer.java create mode 100644 tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Entity1.java create mode 100644 tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Entity2.java create mode 100644 tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Entity3.java create mode 100644 tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Info.java create mode 100644 tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/LineItem.java create mode 100644 tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/MapEntity.java create mode 100644 tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/MapEntityLocal.java create mode 100644 tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Order.java create mode 100644 tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Person.java create mode 100644 tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/PersonId.java create mode 100644 tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Phone.java create mode 100644 tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Product.java create mode 100644 tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/ShelfLife.java create mode 100644 tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/SomeMappedSuperclass.java create mode 100644 tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/SomeMappedSuperclassSubclass.java create mode 100644 tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Spouse.java create mode 100644 tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Thing.java create mode 100644 tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/ThingWithQuantity.java create mode 100644 tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Translation.java create mode 100644 tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/VersionedEntity.java diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Address.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Address.java new file mode 100644 index 0000000000..048e3846b7 --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Address.java @@ -0,0 +1,104 @@ +/* + * 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 . + */ +package org.hibernate.jpamodelgen.test.fromcore; + +import jakarta.persistence.*; + +import java.util.List; + +/** + * TODO : javadoc + * + * @author Steve Ebersole + */ +@Entity +@Table(name = "ADDRESS") +public class Address implements java.io.Serializable { + private String id; + private String street; + private String city; + private String state; + private String zip; + private List phones = new java.util.ArrayList(); + + public Address() { + } + + public Address(String id, String street, String city, String state, String zip) { + this.id = id; + this.street = street; + this.city = city; + this.state = state; + this.zip = zip; + } + + public Address(String id, String street, String city, String state, String zip, + List phones) { + this.id = id; + this.street = street; + this.city = city; + this.state = state; + this.zip = zip; + this.phones = phones; + } + + @Id + @Column(name = "ID") + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @Column(name = "STREET") + public String getStreet() { + return street; + } + + public void setStreet(String street) { + this.street = street; + } + + @Column(name = "CITY") + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + @Column(name = "STATE") + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + @Column(name = "ZIP") + public String getZip() { + return zip; + } + + public void setZip(String zip) { + this.zip = zip; + } + + @OneToMany(cascade = CascadeType.ALL, mappedBy = "address") + @OrderColumn + public List getPhones() { + return phones; + } + + public void setPhones(List phones) { + this.phones = phones; + } +} diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Alias.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Alias.java new file mode 100644 index 0000000000..237afd4d6f --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Alias.java @@ -0,0 +1,99 @@ +/* + * 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 . + */ +package org.hibernate.jpamodelgen.test.fromcore; + +import jakarta.persistence.*; + +import java.util.Collection; + +/** + * TODO : javadoc + * + * @author Steve Ebersole + */ +@Entity +@Table(name = "ALIAS_TABLE") +public class Alias implements java.io.Serializable { + private String id; + private String alias; + private Customer customerNoop; + private Collection customersNoop = new java.util.ArrayList(); + private Collection customers = new java.util.ArrayList(); + + public Alias() { + } + + public Alias(String id, String alias) { + this.id = id; + this.alias = alias; + } + + @Id + @Column(name = "ID") + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @Column(name = "ALIAS") + public String getAlias() { + return alias; + } + + public void setAlias(String alias) { + this.alias = alias; + } + + @OneToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "FK1_FOR_CUSTOMER_TABLE", insertable = false, updatable = false) + public Customer getCustomerNoop() { + return customerNoop; + } + + public void setCustomerNoop(Customer customerNoop) { + this.customerNoop = customerNoop; + } + + @ManyToMany(cascade = CascadeType.ALL) + @JoinTable(name = "FKS_ANOOP_CNOOP", + joinColumns = + @JoinColumn( + name = "FK2_FOR_ALIAS_TABLE", referencedColumnName = "ID"), + inverseJoinColumns = + @JoinColumn( + name = "FK8_FOR_CUSTOMER_TABLE", referencedColumnName = "ID") + ) + public Collection getCustomersNoop() { + return customersNoop; + } + + public void setCustomersNoop(Collection customersNoop) { + this.customersNoop = customersNoop; + + } + + @ManyToMany(cascade = CascadeType.ALL) + @JoinTable(name = "FKS_ALIAS_CUSTOMER", + joinColumns = + @JoinColumn( + name = "FK_FOR_ALIAS_TABLE", referencedColumnName = "ID"), + inverseJoinColumns = + @JoinColumn( + name = "FK_FOR_CUSTOMER_TABLE", referencedColumnName = "ID") + ) + public Collection getCustomers() { + return customers; + } + + public void setCustomers(Collection customers) { + this.customers = customers; + } + +} diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Article.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Article.java new file mode 100644 index 0000000000..dcb4d2b67a --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Article.java @@ -0,0 +1,25 @@ +/* + * 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.jpamodelgen.test.fromcore; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.OneToMany; + +import java.util.Locale; +import java.util.Map; + +/** + * @author Steve Ebersole + */ +@Entity(name = "Article") +public class Article { + @Id + Integer id; + @OneToMany + Map translations; +} diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/BaseEmbeddedEntity.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/BaseEmbeddedEntity.java new file mode 100644 index 0000000000..55f93b1843 --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/BaseEmbeddedEntity.java @@ -0,0 +1,63 @@ + +/* + * 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 . + */ +package org.hibernate.jpamodelgen.test.fromcore; + +import jakarta.persistence.EmbeddedId; +import jakarta.persistence.MappedSuperclass; + +import java.io.Serializable; + +/** + * @author Christian Beikov + */ +@MappedSuperclass +public abstract class BaseEmbeddedEntity implements Serializable { + + private I id; + + public BaseEmbeddedEntity() { + } + + public BaseEmbeddedEntity(I id) { + this.id = id; + } + + @EmbeddedId + public I getId() { + return id; + } + + public void setId(I id) { + this.id = id; + } + + @Override + public int hashCode() { + int hash = 3; + hash = 47 * hash + (this.id != null ? this.id.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final BaseEmbeddedEntity other = (BaseEmbeddedEntity) obj; + if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) { + return false; + } + return true; + } +} diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/CoreTest.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/CoreTest.java new file mode 100644 index 0000000000..b99ae4e4c9 --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/CoreTest.java @@ -0,0 +1,29 @@ +/* + * 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 . + */ +package org.hibernate.jpamodelgen.test.fromcore; + +import org.hibernate.jpamodelgen.test.util.CompilationTest; +import org.hibernate.jpamodelgen.test.util.WithClasses; +import org.junit.Test; + +import static org.hibernate.jpamodelgen.test.util.TestUtil.assertMetamodelClassGeneratedFor; + +/** + * @author Hardy Ferentschik + */ +public class CoreTest extends CompilationTest { + @Test + @WithClasses({MapEntity.class, MapEntityLocal.class, Order.class, LineItem.class, CreditCard.class, Customer.class, + PersonId.class, Phone.class, Person.class, Product.class, BaseEmbeddedEntity.class, VersionedEntity.class, ShelfLife.class, + SomeMappedSuperclass.class, SomeMappedSuperclassSubclass.class, Article.class, Alias.class, Address.class, Info.class, + Country.class, Thing.class, ThingWithQuantity.class, Translation.class, Entity1.class, Entity2.class, Entity3.class}) + public void testGeneratedAnnotationNotGenerated() throws Exception { + for (Class c : getClass().getMethod("testGeneratedAnnotationNotGenerated").getAnnotation(WithClasses.class).value()) { + assertMetamodelClassGeneratedFor(c); + } + } +} diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Country.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Country.java new file mode 100644 index 0000000000..42a9254b2f --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Country.java @@ -0,0 +1,47 @@ +/* + * 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 . + */ +package org.hibernate.jpamodelgen.test.fromcore; +import jakarta.persistence.Basic; +import jakarta.persistence.Embeddable; + +/** + * TODO : javadoc + * + * @author Steve Ebersole + */ +@Embeddable +public class Country implements java.io.Serializable { + private String country; + private String code; + + public Country() { + } + + public Country(String v1, String v2) { + country = v1; + code = v2; + } + + @Basic + public String getCountry() { + return country; + } + + public void setCountry(String v) { + country = v; + } + + @Basic + public String getCode() { + return code; + } + + public void setCode(String v) { + code = v; + } +} + diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/CreditCard.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/CreditCard.java new file mode 100644 index 0000000000..fce388a4c1 --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/CreditCard.java @@ -0,0 +1,129 @@ +/* + * 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 . + */ +package org.hibernate.jpamodelgen.test.fromcore; + +import jakarta.persistence.*; + +/** + * TODO : javadoc + * + * @author Steve Ebersole + */ +@Entity +@Table(name = "CREDITCARD_TABLE") +public class CreditCard implements java.io.Serializable { + private String id; + private String number; + private String type; + private String expires; + private boolean approved; + private double balance; + private Order order; + private Customer customer; + + public CreditCard() { + } + + public CreditCard( + String v1, String v2, String v3, String v4, + boolean v5, double v6, Order v7, Customer v8) { + id = v1; + number = v2; + type = v3; + expires = v4; + approved = v5; + balance = v6; + order = v7; + customer = v8; + } + + public CreditCard( + String v1, String v2, String v3, String v4, + boolean v5, double v6) { + id = v1; + number = v2; + type = v3; + expires = v4; + approved = v5; + balance = v6; + } + + @Id + @Column(name = "ID") + public String getId() { + return id; + } + + public void setId(String v) { + id = v; + } + + @Column(name = "CREDITCARD_NUMBER") + public String getNumber() { + return number; + } + + public void setNumber(String v) { + number = v; + } + + @Column(name = "`TYPE`") + public String getType() { + return type; + } + + public void setType(String v) { + type = v; + } + + @Column(name = "EXPIRES") + public String getExpires() { + return expires; + } + + public void setExpires(String v) { + expires = v; + } + + @Column(name = "APPROVED") + public boolean getApproved() { + return approved; + } + + public void setApproved(boolean v) { + approved = v; + } + + @Column(name = "BALANCE") + public double getBalance() { + return balance; + } + + public void setBalance(double v) { + balance = v; + } + + @OneToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "FK_FOR_ORDER_TABLE") + public Order getOrder() { + return order; + } + + public void setOrder(Order v) { + order = v; + } + + @ManyToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "FK3_FOR_CUSTOMER_TABLE") + public Customer getCustomer() { + return customer; + } + + public void setCustomer(Customer v) { + customer = v; + } +} diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Customer.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Customer.java new file mode 100644 index 0000000000..2f8873431b --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Customer.java @@ -0,0 +1,163 @@ +/* + * 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 . + */ +package org.hibernate.jpamodelgen.test.fromcore; + +import jakarta.persistence.*; + +import java.util.Collection; + +/** + * TODO : javadoc + * + * @author Steve Ebersole + */ +@Entity +@Table(name = "CUSTOMER_TABLE") +public class Customer implements java.io.Serializable { + private String id; + private String name; + private Integer age; + private Address home; + private Address work; + private Country country; + private Spouse spouse; + private Collection creditCards = new java.util.ArrayList(); + private Collection orders = new java.util.ArrayList(); + private Collection aliases = new java.util.ArrayList(); + private Collection aliasesNoop = new java.util.ArrayList(); + + public Customer() { + } + + public Customer(String id, String name) { + this.id = id; + this.name = name; + } + + // Used by test case for HHH-8699. + public Customer(String id, String name, String greeting, Boolean something) { + this.id = id; + this.name = name; + } + + public Customer(String id, String name, Country country) { + this.id = id; + this.name = name; + this.country = country; + } + + public Customer(String id, String name, Address home, + Address work, Country country) { + this.id = id; + this.name = name; + this.home = home; + this.work = work; + this.country = country; + } + + @Id + @Column(name = "ID") + public String getId() { + return id; + } + + public void setId(String v) { + this.id = v; + } + + @Column(name = "NAME") + public String getName() { + return name; + } + + public void setName(String v) { + this.name = v; + } + + @Column(name = "AGE") + public Integer getAge() { + return age; + } + + public void setAge(Integer age) { + this.age = age; + } + + @Embedded + public Country getCountry() { + return country; + } + + public void setCountry(Country v) { + this.country = v; + } + + @OneToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "FK6_FOR_CUSTOMER_TABLE") + public Address getHome() { + return home; + } + + public void setHome(Address v) { + this.home = v; + } + + @OneToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "FK5_FOR_CUSTOMER_TABLE") + public Address getWork() { + return work; + } + + public void setWork(Address v) { + this.work = v; + } + + @OneToOne(cascade = CascadeType.ALL, mappedBy = "customer") + public Spouse getSpouse() { + return spouse; + } + + public void setSpouse(Spouse v) { + this.spouse = v; + } + + @OneToMany(cascade = CascadeType.ALL, mappedBy = "customer") + public Collection getCreditCards() { + return creditCards; + } + + public void setCreditCards(Collection v) { + this.creditCards = v; + } + + @OneToMany(cascade = CascadeType.ALL, mappedBy = "customer") + public Collection getOrders() { + return orders; + } + + public void setOrders(Collection v) { + this.orders = v; + } + + @ManyToMany(cascade = CascadeType.ALL, mappedBy = "customers") + public Collection getAliases() { + return aliases; + } + + public void setAliases(Collection v) { + this.aliases = v; + } + + @ManyToMany(cascade = CascadeType.ALL, mappedBy = "customersNoop") + public Collection getAliasesNoop() { + return aliasesNoop; + } + + public void setAliasesNoop(Collection v) { + this.aliasesNoop = v; + } +} diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Entity1.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Entity1.java new file mode 100644 index 0000000000..e7708f4ea0 --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Entity1.java @@ -0,0 +1,40 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2015, Red Hat Inc. or third-party contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ +package org.hibernate.jpamodelgen.test.fromcore; + +import jakarta.persistence.*; + +@Entity +@Table(name = "entity1") +public class Entity1 { + @Id + private long id; + + @ManyToOne + @JoinColumn(name="entity2_id", nullable = false) + private Entity2 entity2; + + @Column(name = "val") + private String value; +} diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Entity2.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Entity2.java new file mode 100644 index 0000000000..2ef3da0277 --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Entity2.java @@ -0,0 +1,40 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2015, Red Hat Inc. or third-party contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ +package org.hibernate.jpamodelgen.test.fromcore; + +import jakarta.persistence.*; + +@Entity +@Table(name = "entity2") +public class Entity2 { + @Id + private long id; + + @ManyToOne + @JoinColumn(name="entity3_id") + private Entity3 entity3; + + @Column(name = "val") + private String value; +} diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Entity3.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Entity3.java new file mode 100644 index 0000000000..1b7967d7be --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Entity3.java @@ -0,0 +1,39 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2015, Red Hat Inc. or third-party contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ +package org.hibernate.jpamodelgen.test.fromcore; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; + +@Entity +@Table(name = "entity3") +public class Entity3 { + @Id + private long id; + + @Column(name = "val") + private String value; +} diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Info.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Info.java new file mode 100644 index 0000000000..f1653b7e53 --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Info.java @@ -0,0 +1,103 @@ +/* + * 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 . + */ +package org.hibernate.jpamodelgen.test.fromcore; + +import jakarta.persistence.*; + +/** + * TODO : javadoc + * + * @author Steve Ebersole + */ +@Entity +@Table(name = "INFO_TABLE") +public class Info implements java.io.Serializable { + private String id; + private String street; + private String city; + private String state; + private String zip; + private Spouse spouse; + + public Info() { + } + + public Info(String v1, String v2, String v3, String v4, String v5) { + id = v1; + street = v2; + city = v3; + state = v4; + zip = v5; + } + + public Info( + String v1, String v2, String v3, String v4, + String v5, Spouse v6) { + id = v1; + street = v2; + city = v3; + state = v4; + zip = v5; + spouse = v6; + } + + @Id + @Column(name = "ID") + public String getId() { + return id; + } + + public void setId(String v) { + id = v; + } + + @Column(name = "INFOSTREET") + public String getStreet() { + return street; + } + + public void setStreet(String v) { + street = v; + } + + @Column(name = "INFOSTATE") + public String getState() { + return state; + } + + public void setState(String v) { + state = v; + } + + @Column(name = "INFOCITY") + public String getCity() { + return city; + } + + public void setCity(String v) { + city = v; + } + + @Column(name = "INFOZIP") + public String getZip() { + return zip; + } + + public void setZip(String v) { + zip = v; + } + + @OneToOne(mappedBy = "info") @JoinTable( name = "INFO_SPOUSE_TABLE" ) + public Spouse getSpouse() { + return spouse; + } + + public void setSpouse(Spouse v) { + this.spouse = v; + } + +} diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/LineItem.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/LineItem.java new file mode 100644 index 0000000000..d642e14676 --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/LineItem.java @@ -0,0 +1,77 @@ +/* + * 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 . + */ +package org.hibernate.jpamodelgen.test.fromcore; + +import jakarta.persistence.*; + +/** + * TODO : javadoc + * + * @author Steve Ebersole + */ +@Entity +@Table(name = "LINEITEM_TABLE") +public class LineItem implements java.io.Serializable { + private String id; + private int quantity; + private Order order; + private Product product; + + public LineItem() { + } + + public LineItem(String v1, int v2, Order v3, Product v4) { + id = v1; + quantity = v2; + order = v3; + product = v4; + } + + public LineItem(String v1, int v2) { + id = v1; + quantity = v2; + } + + @Id + @Column(name = "ID") + public String getId() { + return id; + } + + public void setId(String v) { + id = v; + } + + @Column(name = "QUANTITY") + public int getQuantity() { + return quantity; + } + + public void setQuantity(int v) { + quantity = v; + } + + @ManyToOne + @JoinColumn(name = "FK1_FOR_ORDER_TABLE") + public Order getOrder() { + return order; + } + + public void setOrder(Order v) { + order = v; + } + + @ManyToOne + @JoinColumn(name = "FK_FOR_PRODUCT_TABLE") + public Product getProduct() { + return product; + } + + public void setProduct(Product v) { + product = v; + } +} diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/MapEntity.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/MapEntity.java new file mode 100644 index 0000000000..2f11092b54 --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/MapEntity.java @@ -0,0 +1,33 @@ +/* + * 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 . + */ +package org.hibernate.jpamodelgen.test.fromcore; + +import jakarta.persistence.*; + +import java.util.Map; + +@Entity +@Table( name = "MAP_ENTITY" ) +public class MapEntity { + + @Id + @Column(name="key_") + private String key; + + @ElementCollection(fetch=FetchType.LAZY) + @CollectionTable(name="MAP_ENTITY_NAME", joinColumns=@JoinColumn(name="key_")) + @MapKeyColumn(name="lang_") + private Map localized; + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } +} diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/MapEntityLocal.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/MapEntityLocal.java new file mode 100644 index 0000000000..46d2fda609 --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/MapEntityLocal.java @@ -0,0 +1,25 @@ +/* + * 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 . + */ +package org.hibernate.jpamodelgen.test.fromcore; + +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; + +@Embeddable +public class MapEntityLocal { + + @Column(name="short_name") + private String shortName; + + public String getShortName() { + return shortName; + } + + public void setShortName(String shortName) { + this.shortName = shortName; + } +} diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Order.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Order.java new file mode 100644 index 0000000000..bcaff4a85a --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Order.java @@ -0,0 +1,145 @@ +/* + * 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 . + */ +package org.hibernate.jpamodelgen.test.fromcore; + +import jakarta.persistence.*; + +import java.util.Collection; + +/** + * TODO : javadoc + * + * @author Steve Ebersole + */ +@Entity +@Table(name = "ORDER_TABLE") +public class Order implements java.io.Serializable { + private String id; + private double totalPrice; + private Customer customer; + private CreditCard creditCard; + private LineItem sampleLineItem; + private Collection lineItems = new java.util.ArrayList(); + + private char[] domen; + private byte[] number; + + public Order() { + } + + public Order(String id, double totalPrice) { + this.id = id; + this.totalPrice = totalPrice; + } + + public Order(String id, Customer customer) { + this.id = id; + this.customer = customer; + } + + public Order(String id, char[] domen) { + this.id = id; + this.domen = domen; + } + + + public Order(String id) { + this.id = id; + } + + //==================================================================== + // getters and setters for State fields + + @Id + @Column(name = "ID") + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @Column(name = "TOTALPRICE") + public double getTotalPrice() { + return totalPrice; + } + + public void setTotalPrice(double price) { + this.totalPrice = price; + } + + //==================================================================== + // getters and setters for Association fields + + // MANYx1 + + @ManyToOne + @JoinColumn( + name = "FK4_FOR_CUSTOMER_TABLE") + public Customer getCustomer() { + return customer; + } + + public void setCustomer(Customer customer) { + this.customer = customer; + } + + //1x1 + + @OneToOne(mappedBy = "order") + public CreditCard getCreditCard() { + return creditCard; + } + + public void setCreditCard(CreditCard cc) { + this.creditCard = cc; + } + + // 1x1 + + @OneToOne(cascade = CascadeType.REMOVE) + @JoinColumn( + name = "FK0_FOR_LINEITEM_TABLE") + public LineItem getSampleLineItem() { + return sampleLineItem; + } + + public void setSampleLineItem(LineItem l) { + this.sampleLineItem = l; + } + + //1xMANY + + @OneToMany(cascade = CascadeType.ALL, mappedBy = "order") + public Collection getLineItems() { + return lineItems; + } + + public void setLineItems(Collection c) { + this.lineItems = c; + } + + public char[] getDomen() { + return domen; + } + + public void setDomen(char[] d) { + domen = d; + } + + @Column(name="fld_number") + public byte[] getNumber() { + return number; + } + + public void setNumber(byte[] n) { + number = n; + } + + +} diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Person.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Person.java new file mode 100644 index 0000000000..0ea38d3393 --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Person.java @@ -0,0 +1,44 @@ +/* + * 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 . + */ +package org.hibernate.jpamodelgen.test.fromcore; + +import jakarta.persistence.Entity; + +/** + * @author Christian Beikov + */ +@Entity +public class Person extends BaseEmbeddedEntity { + + private String firstName; + private String lastName; + + public Person() { + } + + public Person(PersonId id, String firstName, String lastName) { + super(id); + this.firstName = firstName; + this.lastName = lastName; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } +} diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/PersonId.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/PersonId.java new file mode 100644 index 0000000000..cae50beb10 --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/PersonId.java @@ -0,0 +1,74 @@ +/* + * 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 . + */ +package org.hibernate.jpamodelgen.test.fromcore; + +import jakarta.persistence.Embeddable; + +import java.io.Serializable; + +/** + * @author Christian Beikov + */ +@Embeddable +public class PersonId implements Serializable { + + private String ssn; + private String name; + + public PersonId() { + } + + public PersonId(String ssn, String name) { + this.ssn = ssn; + this.name = name; + } + + public String getSsn() { + return ssn; + } + + public void setSsn(String ssn) { + this.ssn = ssn; + } + + public String getName() { + return name; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 67 * hash + (this.ssn != null ? this.ssn.hashCode() : 0); + hash = 67 * hash + (this.name != null ? this.name.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final PersonId other = (PersonId) obj; + if ((this.ssn == null) ? (other.ssn != null) : !this.ssn.equals(other.ssn)) { + return false; + } + if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + return false; + } + return true; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Phone.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Phone.java new file mode 100644 index 0000000000..ed65185a09 --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Phone.java @@ -0,0 +1,91 @@ +/* + * 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 . + */ +package org.hibernate.jpamodelgen.test.fromcore; + +import jakarta.persistence.*; + +import java.util.Set; + +/** + * TODO : javadoc + * + * @author Steve Ebersole + */ +@Entity +@Table(name = "PHONE_TABLE") +public class Phone implements java.io.Serializable { + public enum Type { LAND_LINE, CELL, FAX, WORK, HOME } + + private String id; + private String area; + private String number; + private Address address; + private Set types; + + public Phone() { + } + + public Phone(String v1, String v2, String v3) { + id = v1; + area = v2; + number = v3; + } + + public Phone(String v1, String v2, String v3, Address v4) { + id = v1; + area = v2; + number = v3; + address = v4; + } + + @Id + @Column(name = "ID") + public String getId() { + return id; + } + + public void setId(String v) { + id = v; + } + + @Column(name = "AREA") + public String getArea() { + return area; + } + + public void setArea(String v) { + area = v; + } + + @Column(name = "PHONE_NUMBER") + public String getNumber() { + return number; + } + + public void setNumber(String v) { + number = v; + } + + @ManyToOne + @JoinColumn(name = "FK_FOR_ADDRESS") + public Address getAddress() { + return address; + } + + public void setAddress(Address a) { + address = a; + } + + @ElementCollection + public Set getTypes() { + return types; + } + + public void setTypes(Set types) { + this.types = types; + } +} diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Product.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Product.java new file mode 100644 index 0000000000..fbede5b371 --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Product.java @@ -0,0 +1,142 @@ +/* + * 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 . + */ +package org.hibernate.jpamodelgen.test.fromcore; + +import jakarta.persistence.*; + +import java.math.BigDecimal; +import java.math.BigInteger; + +/** + * TODO : javadoc + * + * @author Steve Ebersole + */ +@Entity +@Table(name = "PRODUCT_TABLE") +@SecondaryTable(name = "PRODUCT_DETAILS", pkJoinColumns = @PrimaryKeyJoinColumn(name = "ID")) +@Inheritance(strategy = InheritanceType.SINGLE_TABLE) +@DiscriminatorColumn(name = "PRODUCT_TYPE", discriminatorType = DiscriminatorType.STRING) +@DiscriminatorValue("Product") +public class Product implements java.io.Serializable { + private String id; + private String name; + private double price; + private float rating; + private int quantity; + private long partNumber; + private BigInteger someBigInteger; + private BigDecimal someBigDecimal; + private String wareHouse; + private ShelfLife shelfLife; + + public Product() { + } + + public Product(String id, String name, double price, int quantity, long partNumber) { + this.id = id; + this.name = name; + this.price = price; + this.quantity = quantity; + this.partNumber = partNumber; + } + + @Id + @Column(name = "ID") + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @Column(name = "NAME") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Column(name = "PRICE") + public double getPrice() { + return price; + } + + public void setPrice(double price) { + this.price = price; + } + + @Column(name = "QUANTITY") + public int getQuantity() { + return quantity; + } + + public void setQuantity(int v) { + this.quantity = v; + } + + @Column(name = "PNUM") + public long getPartNumber() { + return partNumber; + } + + public void setPartNumber(long v) { + this.partNumber = v; + } + + public float getRating() { + return rating; + } + + public void setRating(float rating) { + this.rating = rating; + } + + public BigInteger getSomeBigInteger() { + return someBigInteger; + } + + public void setSomeBigInteger(BigInteger someBigInteger) { + this.someBigInteger = someBigInteger; + } + + @Column( precision = 10, scale = 3) + public BigDecimal getSomeBigDecimal() { + return someBigDecimal; + } + + public void setSomeBigDecimal(BigDecimal someBigDecimal) { + this.someBigDecimal = someBigDecimal; + } + + @Column(name = "WHOUSE", nullable = true, table = "PRODUCT_DETAILS") + public String getWareHouse() { + return wareHouse; + } + + public void setWareHouse(String v) { + this.wareHouse = v; + } + + @Embedded + @AttributeOverrides({ + @AttributeOverride(name = "inceptionDate", + column = @Column(name = "INCEPTION", nullable = true)), + @AttributeOverride(name = "soldDate", + column = @Column(name = "SOLD", nullable = true)) + }) + public ShelfLife getShelfLife() { + return shelfLife; + } + + public void setShelfLife(ShelfLife v) { + this.shelfLife = v; + } +} diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/ShelfLife.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/ShelfLife.java new file mode 100644 index 0000000000..98d1917d3c --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/ShelfLife.java @@ -0,0 +1,44 @@ +/* + * 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 . + */ +package org.hibernate.jpamodelgen.test.fromcore; + +import jakarta.persistence.Basic; +import jakarta.persistence.Embeddable; + +import java.sql.Date; + +@Embeddable +public class ShelfLife implements java.io.Serializable { + private Date inceptionDate; + private Date soldDate; + + public ShelfLife() { + } + + public ShelfLife(Date inceptionDate, Date soldDate) { + this.inceptionDate = inceptionDate; + this.soldDate = soldDate; + } + + @Basic + public Date getInceptionDate() { + return inceptionDate; + } + + public void setInceptionDate(Date inceptionDate) { + this.inceptionDate = inceptionDate; + } + + @Basic + public Date getSoldDate() { + return soldDate; + } + + public void setSoldDate(Date soldDate) { + this.soldDate = soldDate; + } +} diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/SomeMappedSuperclass.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/SomeMappedSuperclass.java new file mode 100644 index 0000000000..62d74412ef --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/SomeMappedSuperclass.java @@ -0,0 +1,27 @@ +/* + * 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 . + */ +package org.hibernate.jpamodelgen.test.fromcore; + +import jakarta.persistence.Id; +import jakarta.persistence.MappedSuperclass; + +/** + * @author Steve Ebersole + */ +@MappedSuperclass +public class SomeMappedSuperclass { + private Long id; + + @Id + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } +} diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/SomeMappedSuperclassSubclass.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/SomeMappedSuperclassSubclass.java new file mode 100644 index 0000000000..ba06afc307 --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/SomeMappedSuperclassSubclass.java @@ -0,0 +1,25 @@ +/* + * 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 . + */ +package org.hibernate.jpamodelgen.test.fromcore; + +import jakarta.persistence.Entity; + +/** + * @author Steve Ebersole + */ +@Entity +public class SomeMappedSuperclassSubclass extends SomeMappedSuperclass { + private String theData; + + public String getTheData() { + return theData; + } + + public void setTheData(String theData) { + this.theData = theData; + } +} diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Spouse.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Spouse.java new file mode 100644 index 0000000000..bfc69cb70e --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Spouse.java @@ -0,0 +1,120 @@ +/* + * 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 . + */ +package org.hibernate.jpamodelgen.test.fromcore; + +import jakarta.persistence.*; + +/** + * TODO : javadoc + * + * @author Steve Ebersole + */ +@Entity +@Table(name = "SPOUSE_TABLE") +public class Spouse implements java.io.Serializable { + private String id; + private String first; + private String maiden; + private String last; + private String sNumber; + private Info info; + private Customer customer; + + public Spouse() { + } + + public Spouse( + String v1, String v2, String v3, String v4, + String v5, Info v6) { + id = v1; + first = v2; + maiden = v3; + last = v4; + sNumber = v5; + info = v6; + } + + + public Spouse( + String v1, String v2, String v3, String v4, + String v5, Info v6, Customer v7) { + id = v1; + first = v2; + maiden = v3; + last = v4; + sNumber = v5; + info = v6; + customer = v7; + } + + @Id + @Column(name = "ID") + public String getId() { + return id; + } + + public void setId(String v) { + id = v; + } + + @Column(name = "FIRSTNAME") + public String getFirstName() { + return first; + } + + public void setFirstName(String v) { + first = v; + } + + @Column(name = "MAIDENNAME") + public String getMaidenName() { + return maiden; + } + + public void setMaidenName(String v) { + maiden = v; + } + + @Column(name = "LASTNAME") + public String getLastName() { + return last; + } + + public void setLastName(String v) { + last = v; + } + + @Column(name = "SOCSECNUM") + public String getSocialSecurityNumber() { + return sNumber; + } + + public void setSocialSecurityNumber(String v) { + sNumber = v; + } + + @OneToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "FK_FOR_INFO_TABLE") + public Info getInfo() { + return info; + } + + public void setInfo(Info v) { + info = v; + } + + @OneToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "FK7_FOR_CUSTOMER_TABLE") + public Customer getCustomer() { + return customer; + } + + public void setCustomer(Customer v) { + customer = v; + } + +} diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Thing.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Thing.java new file mode 100644 index 0000000000..18db245b14 --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Thing.java @@ -0,0 +1,39 @@ +/* + * 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 . + */ +package org.hibernate.jpamodelgen.test.fromcore; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Inheritance; +import jakarta.persistence.InheritanceType; + +/** + * @author James Gilbertson + */ +@Entity +@Inheritance(strategy = InheritanceType.JOINED) +public class Thing { + private String id; + private String name; + + @Id + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/ThingWithQuantity.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/ThingWithQuantity.java new file mode 100644 index 0000000000..8004a63fd5 --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/ThingWithQuantity.java @@ -0,0 +1,25 @@ +/* + * 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 . + */ +package org.hibernate.jpamodelgen.test.fromcore; + +import jakarta.persistence.Entity; + +/** + * @author James Gilbertson + */ +@Entity +public class ThingWithQuantity extends Thing { + private int quantity; + + public int getQuantity() { + return quantity; + } + + public void setQuantity(int quantity) { + this.quantity = quantity; + } +} diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Translation.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Translation.java new file mode 100644 index 0000000000..be83552217 --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/Translation.java @@ -0,0 +1,23 @@ +/* + * 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.jpamodelgen.test.fromcore; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; + +/** + * @author Steve Ebersole + */ +@Entity +@Table(name = "translation_tbl") +public class Translation { + @Id + Integer id; + String title; + String text; +} diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/VersionedEntity.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/VersionedEntity.java new file mode 100644 index 0000000000..8fcbd53f41 --- /dev/null +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/fromcore/VersionedEntity.java @@ -0,0 +1,47 @@ +/* + * 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 . + */ +package org.hibernate.jpamodelgen.test.fromcore; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Version; + +/** + * @author Steve Ebersole + */ +@Entity +public class VersionedEntity { + private String id; + private String name; + private int version; + + @Id + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Version + public int getVersion() { + return version; + } + + public void setVersion(int version) { + this.version = version; + } +}