[JIRA] (HHH-16341) PostgresPlusDialect uses postgresql jdbc driver classes even when EBD driver is used
by Martin Simka (JIRA)
Martin Simka ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *created* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiZDIzYmM1MTdh... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16341?atlOrigin=eyJpIjoiZDIzYm... ) HHH-16341 ( https://hibernate.atlassian.net/browse/HHH-16341?atlOrigin=eyJpIjoiZDIzYm... ) PostgresPlusDialect uses postgresql jdbc driver classes even when EBD driver is used ( https://hibernate.atlassian.net/browse/HHH-16341?atlOrigin=eyJpIjoiZDIzYm... )
Issue Type: Bug Affects Versions: 6.2.0.CR4 Assignee: Unassigned Created: 21/Mar/2023 06:04 AM Environment: Hibernate ORM 6.2.0.CR4 + EnterpriseDB 14.4 + EDB JDBC Connector 42.5.0.1 + extra connection parameters: `preparedStatementCacheQueries=0&escapeSyntaxCallMode=callIfNoReturn` Priority: Critical Reporter: Martin Simka ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
PostgreSQLInetTypes*Test fail with EnterpriseDB when EDB JDBC Connector connector is used.
Example failure:
Caused by:
org.hibernate.exception.SQLGrammarException: Unable to bind parameter #1 - 192.168.0.123/24 [Can't infer the SQL type to use for an instance of org.postgresql.util.PGobject. Use setObject() with an explicit Types value to specify the type to use.] [n/a]
at app//org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:89)
at app//org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:56)
at app//org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:108)
at app//org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:94)
at app//org.hibernate.engine.jdbc.mutation.internal.JdbcValueBindingsImpl.lambda$beforeStatement$0(JdbcValueBindingsImpl.java:95)
at java.base@11.0.17/java.lang.Iterable.forEach(Iterable.java:75)
at app//org.hibernate.engine.jdbc.mutation.spi.BindingGroup.forEachBinding(BindingGroup.java:51)
at app//org.hibernate.engine.jdbc.mutation.internal.JdbcValueBindingsImpl.beforeStatement(JdbcValueBindingsImpl.java:85)
at app//org.hibernate.engine.jdbc.mutation.internal.AbstractMutationExecutor.performNonBatchedMutation(AbstractMutationExecutor.java:93)
at app//org.hibernate.engine.jdbc.mutation.internal.MutationExecutorSingleNonBatched.performNonBatchedOperations(MutationExecutorSingleNonBatched.java:40)
at app//org.hibernate.engine.jdbc.mutation.internal.AbstractMutationExecutor.execute(AbstractMutationExecutor.java:43)
at app//org.hibernate.persister.entity.mutation.InsertCoordinator.doStaticInserts(InsertCoordinator.java:168)
at app//org.hibernate.persister.entity.mutation.InsertCoordinator.coordinateInsert(InsertCoordinator.java:110)
at app//org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2775)
at app//org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:102)
at app//org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:616)
at app//org.hibernate.engine.spi.ActionQueue.lambda$executeActions$1(ActionQueue.java:487)
at java.base@11.0.17/java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
at app//org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:484)
at app//org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:358)
at app//org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)
at app//org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:127)
at app//org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1412)
at app//org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:485)
at app//org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:2296)
at app//org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:1961)
at app//org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:426)
at app//org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:169)
at app//org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:267)
at app//org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:101)
... 3 more
Caused by:
com.edb.util.PSQLException: Can't infer the SQL type to use for an instance of org.postgresql.util.PGobject. Use setObject() with an explicit Types value to specify the type to use.
at app//com.edb.jdbc.PgPreparedStatement.setObject(PgPreparedStatement.java:1107)
at app//org.hibernate.dialect.PostgreSQLInetJdbcType$1.doBind(PostgreSQLInetJdbcType.java:80)
at app//org.hibernate.type.descriptor.jdbc.BasicBinder.bind(BasicBinder.java:61)
at app//org.hibernate.engine.jdbc.mutation.internal.JdbcValueBindingsImpl.lambda$beforeStatement$0(JdbcValueBindingsImpl.java:87)
... 28 more
PostgreSQLInetJdbcType uses org.postgresql.util.PGobject , but with EDB JDBC Connector it should probably use com.edb.util.PGobject
( https://hibernate.atlassian.net/browse/HHH-16341#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16341#add-comment?atlOrigin=ey... )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100218- sha1:518c67a )
3 years
[JIRA] (HHH-16340) Duplicate column exception when using an EmbeddedId in a structure with Inheritance - Hibernate V6
by Brian Forkan (JIRA)
Brian Forkan ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *updated* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiN2M4NDQwOTNi... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16340?atlOrigin=eyJpIjoiN2M4ND... ) HHH-16340 ( https://hibernate.atlassian.net/browse/HHH-16340?atlOrigin=eyJpIjoiN2M4ND... ) Duplicate column exception when using an EmbeddedId in a structure with Inheritance - Hibernate V6 ( https://hibernate.atlassian.net/browse/HHH-16340?atlOrigin=eyJpIjoiN2M4ND... )
Change By: Brian Forkan ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
{noformat}Caused by: org.hibernate.MappingException: Column 'TYPE' is duplicated in mapping for entity 'org.hibernate.bugs.JPAUnitTestCase$Node' (use '@Column(insertable=false, updatable=false)' when mapping multiple properties to the same column){noformat}
The exception above happens in Hibernate 6.0 and above.
[https://github.com/ brianforkan hibernate /hibernate-test-case-templates/ commit compare / ea51a1f55b248edacebd6e5aab5e8a071a8ad296 main...brianforkan:hibernate-test-case-templates:embeddedid-inheritence |https://github.com/ brianforkan hibernate /hibernate-test-case-templates/ commit compare / ea51a1f55b248edacebd6e5aab5e8a071a8ad296 main...brianforkan:hibernate-test-case-templates:embeddedid-inheritence |smart-link]
I have created two test cases, one for Hibernate 5, which works fine and one for Hibernate 6 which fails.
Following the suggestion in the exception does not fix the problem.
This is the structure I am using:
{noformat} @Entity(name = "Node")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "TYPE")
@DiscriminatorOptions(insert = false)
public static class Node {
@EmbeddedId
private NodeId id;
@Column(name = "NAME")
private String name;
public Node(NodeId id, String name) {
this.id = id;
this.name = name;
}
public NodeId getId() {
return id;
}
public void setId(NodeId id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
protected Node() {
}
}
@Entity
@DiscriminatorValue("NODEA")
public static class NodeA extends Node {
protected NodeA() {
}
public NodeA(NodeId nodeId, String name) {
super(nodeId, name);
}
}
@Entity
@DiscriminatorValue("NODEB")
public static class NodeB extends Node {
protected NodeB() {
}
public NodeB(NodeId nodeId, String name) {
super(nodeId, name);
}
}
@Embeddable
public static class NodeId implements Serializable {
@Column(name = "ID")
private String id;
public String getId() {
return id;
}
public NodeId() {}
public NodeId(String id, String type) {
this.id = id;
this.type = type;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
NodeId nodeId = (NodeId) o;
if (!Objects.equals(id, nodeId.id)) {
return false;
}
return Objects.equals(type, nodeId.type);
}
@Override
public int hashCode() {
int result = id != null ? id.hashCode() : 0;
result = 31 * result + (type != null ? type.hashCode() : 0);
return result;
}
public void setId(String id) {
this.id = id;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@Column(name = "TYPE")
private String type;
}{noformat}
( https://hibernate.atlassian.net/browse/HHH-16340#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16340#add-comment?atlOrigin=ey... )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100218- sha1:518c67a )
3 years
[JIRA] (HHH-16340) Duplicate column exception when using an EmbeddedId in a structure with Inheritance - Hibernate V6
by Brian Forkan (JIRA)
Brian Forkan ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *updated* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiMTVhOGRmYmY5... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16340?atlOrigin=eyJpIjoiMTVhOG... ) HHH-16340 ( https://hibernate.atlassian.net/browse/HHH-16340?atlOrigin=eyJpIjoiMTVhOG... ) Duplicate column exception when using an EmbeddedId in a structure with Inheritance - Hibernate V6 ( https://hibernate.atlassian.net/browse/HHH-16340?atlOrigin=eyJpIjoiMTVhOG... )
Change By: Brian Forkan ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
{noformat}Caused by: org.hibernate.MappingException: Column 'TYPE' is duplicated in mapping for entity 'org.hibernate.bugs.JPAUnitTestCase$Node' (use '@Column(insertable=false, updatable=false)' when mapping multiple properties to the same column){noformat}
The exception above happens in Hibernate 6.0 and above.
[https://github.com/brianforkan/hibernate-test-case-templates/commit/ea51a...]
I have created two test cases, one for Hibernate 5, which works fine and one for Hibernate 6 which fails.
Following the suggestion in the exception does not fix the problem.
This is the structure I am using:
{noformat} @Entity(name = "Node")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "TYPE")
@DiscriminatorOptions(insert = false)
public static class Node {
@EmbeddedId
private NodeId id;
@Column(name = "NAME")
private String name;
public Node(NodeId id, String name) {
this.id = id;
this.name = name;
}
public NodeId getId() {
return id;
}
public void setId(NodeId id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
protected Node() {
}
}
@Entity
@DiscriminatorValue("NODEA")
public static class NodeA extends Node {
protected NodeA() {
}
public NodeA(NodeId nodeId, String name) {
super(nodeId, name);
}
}
@Entity
@DiscriminatorValue("NODEB")
public static class NodeB extends Node {
protected NodeB() {
}
public NodeB(NodeId nodeId, String name) {
super(nodeId, name);
}
}
@Embeddable
public static class NodeId implements Serializable {
@Column(name = "ID")
private String id;
public String getId() {
return id;
}
public NodeId() {}
public NodeId(String id, String type) {
this.id = id;
this.type = type;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
NodeId nodeId = (NodeId) o;
if (!Objects.equals(id, nodeId.id)) {
return false;
}
return Objects.equals(type, nodeId.type);
}
@Override
public int hashCode() {
int result = id != null ? id.hashCode() : 0;
result = 31 * result + (type != null ? type.hashCode() : 0);
return result;
}
public void setId(String id) {
this.id = id;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@Column(name = "TYPE" , insertable = false, updatable = false )
private String type;
}{noformat}
( https://hibernate.atlassian.net/browse/HHH-16340#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16340#add-comment?atlOrigin=ey... )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100218- sha1:518c67a )
3 years
[JIRA] (HHH-16340) Duplicate column exception when using an EmbeddedId in a structure with Inheritance - Hibernate V6
by Brian Forkan (JIRA)
Brian Forkan ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *updated* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiZWEyYzFkMjVl... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16340?atlOrigin=eyJpIjoiZWEyYz... ) HHH-16340 ( https://hibernate.atlassian.net/browse/HHH-16340?atlOrigin=eyJpIjoiZWEyYz... ) Duplicate column exception when using an EmbeddedId in a structure with Inheritance - Hibernate V6 ( https://hibernate.atlassian.net/browse/HHH-16340?atlOrigin=eyJpIjoiZWEyYz... )
Change By: Brian Forkan ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
{noformat}Caused by: org.hibernate.MappingException: Column 'TYPE' is duplicated in mapping for entity 'org.hibernate.bugs.JPAUnitTestCase$Node' (use '@Column(insertable=false, updatable=false)' when mapping multiple properties to the same column){noformat}
The exception above happens in Hibernate 6.0 and above.
[https://github.com/brianforkan/hibernate-test-case-templates/commit/ea51a...]
I have created two test cases, one for Hibernate 5, which works fine and one for Hibernate 6 which fails.
Following the suggestion in the exception does not fix the problem.
This is the structure I am using:
{noformat} @Entity(name = "Node")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "TYPE")
@DiscriminatorOptions(insert = false)
public static class Node {
@EmbeddedId
private NodeId id;
@Column(name = "NAME")
private String name;
public Node(NodeId id, String name) {
this.id = id;
this.name = name;
}
public NodeId getId() {
return id;
}
public void setId(NodeId id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
protected Node() {
}
}
@Entity
@DiscriminatorValue("NODEA")
public static class NodeA extends Node {
protected NodeA() {
}
public NodeA(NodeId nodeId, String name) {
super(nodeId, name);
}
}
@Entity
@DiscriminatorValue("NODEB")
public static class NodeB extends Node {
protected NodeB() {
}
public NodeB(NodeId nodeId, String name) {
super(nodeId, name);
}
}
@Embeddable
public static class NodeId implements Serializable {
@Column(name = "ID")
private String id;
public String getId() {
return id;
}
public NodeId() {}
public NodeId(String id, String type) {
this.id = id;
this.type = type;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
NodeId nodeId = (NodeId) o;
if (!Objects.equals(id, nodeId.id)) {
return false;
}
return Objects.equals(type, nodeId.type);
}
@Override
public int hashCode() {
int result = id != null ? id.hashCode() : 0;
result = 31 * result + (type != null ? type.hashCode() : 0);
return result;
}
public void setId(String id) {
this.id = id;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@Column(name = "TYPE", insertable = false, updatable = false)
private String type;
}{noformat}
( https://hibernate.atlassian.net/browse/HHH-16340#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16340#add-comment?atlOrigin=ey... )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100218- sha1:518c67a )
3 years
[JIRA] (HHH-16340) Duplicate column exception when using an EmbeddedId in a structure with Inheritance - Hibernate V6
by Brian Forkan (JIRA)
Brian Forkan ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *created* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNzg2NjAwYTE1... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16340?atlOrigin=eyJpIjoiNzg2Nj... ) HHH-16340 ( https://hibernate.atlassian.net/browse/HHH-16340?atlOrigin=eyJpIjoiNzg2Nj... ) Duplicate column exception when using an EmbeddedId in a structure with Inheritance - Hibernate V6 ( https://hibernate.atlassian.net/browse/HHH-16340?atlOrigin=eyJpIjoiNzg2Nj... )
Issue Type: Bug Affects Versions: 6.0.0 Assignee: Unassigned Components: hibernate-orm-modules Created: 21/Mar/2023 04:18 AM Environment: Java 17
Hibernate ORM >6.0 Priority: Major Reporter: Brian Forkan ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
Caused by: org.hibernate.MappingException: Column 'TYPE' is duplicated in mapping for entity 'org.hibernate.bugs.JPAUnitTestCase$Node' (use '@Column(insertable=false, updatable=false)' when mapping multiple properties to the same column)
The exception above happens in Hibernate 6.0 and above.
https://github.com/brianforkan/hibernate-test-case-templates/commit/ea51a... ( https://github.com/brianforkan/hibernate-test-case-templates/commit/ea51a... )
I have created two test cases, one for Hibernate 5, which works fine and one for Hibernate 6 which fails.
This is the structure I am using:
@Entity(name = "Node")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "TYPE")
@DiscriminatorOptions(insert = false)
public static class Node {
@EmbeddedId
private NodeId id;
@Column(name = "NAME")
private String name;
public Node(NodeId id, String name) {
this.id = id;
this.name = name;
}
public NodeId getId() {
return id;
}
public void setId(NodeId id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
protected Node() {
}
}
@Entity
@DiscriminatorValue("NODEA")
public static class NodeA extends Node {
protected NodeA() {
}
public NodeA(NodeId nodeId, String name) {
super(nodeId, name);
}
}
@Entity
@DiscriminatorValue("NODEB")
public static class NodeB extends Node {
protected NodeB() {
}
public NodeB(NodeId nodeId, String name) {
super(nodeId, name);
}
}
@Embeddable
public static class NodeId implements Serializable {
@Column(name = "ID")
private String id;
public String getId() {
return id;
}
public NodeId() {}
public NodeId(String id, String type) {
this.id = id;
this.type = type;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
NodeId nodeId = (NodeId) o;
if (!Objects.equals(id, nodeId.id)) {
return false;
}
return Objects.equals(type, nodeId.type);
}
@Override
public int hashCode() {
int result = id != null ? id.hashCode() : 0;
result = 31 * result + (type != null ? type.hashCode() : 0);
return result;
}
public void setId(String id) {
this.id = id;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@Column(name = "TYPE", insertable = false, updatable = false)
private String type;
}
( https://hibernate.atlassian.net/browse/HHH-16340#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16340#add-comment?atlOrigin=ey... )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100218- sha1:518c67a )
3 years