-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Regression test for issue #16860 resolved by HHH-14575
- Loading branch information
Showing
4 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/basicproxy/AbstractEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package io.quarkus.it.jpa.h2.basicproxy; | ||
|
||
import java.io.Serializable; | ||
import java.util.Objects; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.DiscriminatorColumn; | ||
import javax.persistence.Entity; | ||
import javax.persistence.Id; | ||
import javax.persistence.Table; | ||
|
||
@Entity | ||
@Table(name = "ENTITY") | ||
@DiscriminatorColumn(name = "TYPE") | ||
public abstract class AbstractEntity implements Serializable { | ||
|
||
public AbstractEntity() { | ||
// nop | ||
} | ||
|
||
@Id | ||
@Column(name = "TYPE", insertable = false, updatable = false) | ||
public String type; | ||
|
||
@Id | ||
@Column(name = "ID") | ||
public String id; | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) | ||
return true; | ||
if (o == null || getClass() != o.getClass()) | ||
return false; | ||
AbstractEntity that = (AbstractEntity) o; | ||
return Objects.equals(type, that.type) && Objects.equals(id, that.id); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(type, id); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...on-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/basicproxy/BasicProxyTestEndpoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package io.quarkus.it.jpa.h2.basicproxy; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.enterprise.event.Observes; | ||
import javax.inject.Inject; | ||
import javax.persistence.EntityManager; | ||
import javax.servlet.annotation.WebServlet; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import javax.transaction.Transactional; | ||
|
||
import io.quarkus.runtime.StartupEvent; | ||
|
||
@ApplicationScoped | ||
@WebServlet(urlPatterns = "/jpa-h2/testbasicproxy") | ||
public class BasicProxyTestEndpoint extends HttpServlet { | ||
|
||
@Inject | ||
EntityManager entityManager; | ||
|
||
@Transactional | ||
public void setup(@Observes StartupEvent startupEvent) { | ||
ConcreteEntity entity = new ConcreteEntity(); | ||
entity.id = "1"; | ||
entity.type = "Concrete"; | ||
entityManager.persist(entity); | ||
} | ||
|
||
@Override | ||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { | ||
final List list = entityManager.createQuery("from ConcreteEntity").getResultList(); | ||
if (list.size() != 1) { | ||
throw new RuntimeException("Expected 1 result, got " + list.size()); | ||
} | ||
resp.getWriter().write("OK"); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
integration-tests/jpa-h2/src/main/java/io/quarkus/it/jpa/h2/basicproxy/ConcreteEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package io.quarkus.it.jpa.h2.basicproxy; | ||
|
||
import javax.persistence.DiscriminatorValue; | ||
import javax.persistence.Entity; | ||
|
||
@Entity | ||
@DiscriminatorValue("Concrete") | ||
public class ConcreteEntity extends AbstractEntity { | ||
|
||
public ConcreteEntity() { | ||
super(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters