Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Cannot insert to 'path' field in Postgres db using EclipseLink(postgres)
Cannot insert to 'path' field in Postgres db using EclipseLink [message #1270048] Wed, 12 March 2014 12:48 Go to next message
Daryl Foster is currently offline Daryl Foster
Messages: 3
Registered: March 2014
Junior Member
I'm not sure if this is the right place for this question, but I have a java app running in JBoss that uses EclipseLink to persist to a Postgres database. I've added a field with a 'path' datatype to one of the tables but I keep getting the following exception when I try to insert data:

org.postgresql.util.PSQLException: Can't infer the SQL type to use for an instance of org.postgresql.geometric.PGpath. Use setObject() with an explicit Types value to specify the type to use.

Here's the table definition:

CREATE TABLE schema.table_name
(
item_id uuid NOT NULL,
item_path path NOT NULL
)

The java entity is representing the item_path field as a List<Point> object, and I'm using a converter to map from the List<Point> object to a PGpath object:

import org.eclipse.persistence.mappings.DatabaseMapping;
import org.eclipse.persistence.mappings.converters.Converter;
import org.eclipse.persistence.sessions.Session;
import org.postgresql.geometric.PGpath;
import java.awt.Point;
import java.util.ArrayList;
import java.util.List;
import static java.sql.Types.OTHER;

public class PgPathConverter implements Converter
{
@Override
public boolean isMutable ()
{
return false;
}

@Override
public List<Point> convertDataValueToObjectValue (Object value, Session session)
{
// Code that converts PGpath to List<Point>
}

@Override
public PGpath convertObjectValueToDataValue (Object value, Session session)
{
// Code that converts List<Point> to PGpath
}

@Override
public void initialize (DatabaseMapping mapping, Session session)
{
mapping.getField ().setSqlType (OTHER);
}
}

The entity class is defined as follows:

@Entity
@Table (
name = "table_name",
schema = "schema"
)
@Converter (
name = "path",
converterClass = PgPathConverter.class
)
public class TableName
{
public TableName () {}
private static final long serialVersionUID = 1L;

@Column (name = "item_path")
@Convert ("path")
private List<Point> m_ItemPath;

@Id
@Column (
name = "item_id",
unique = true,
nullable = false
)
private UUID m_ItemId;

public UUID getItemId ()
{
return m_ItemId;
}

public List<Point> getItemPath ()
{
return m_InkPath;
}

public void setItemId (UUID itemId)
{
m_ItemId = itemId;
}

public void setInkPath (List<Point> itemPath)
{
m_ItemPath = itemPath;
}
}

Finally, here's the exception I get when I call `EntityManager.persist (entity)`:

18:10:33,789 ERROR [org.jboss.as.ejb3] (http-/0.0.0.0:8080-1) javax.ejb.EJBTransactionRolledbackException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: Can't infer the SQL type to use for an instance of org.postgresql.geometric.PGpath. Use setObject() with an explicit Types value to specify the type to use.
Error Code: 0
Call: INSERT INTO schema.table_name (item_id, item_path) VALUES (?, ?)
bind => [2 parameters bound]
18:10:33,789 ERROR [org.jboss.as.ejb3.invocation] (http-/0.0.0.0:8080-1) JBAS014134: EJB Invocation failed on component TableNameRepository for method public void com.mycompany.myproject.data.Repository.flush() throws javax.persistence.TransactionRequiredException,javax.persistence.PersistenceException: javax.ejb.EJBTransactionRolledbackException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: Can't infer the SQL type to use for an instance of org.postgresql.geometric.PGpath. Use setObject() with an explicit Types value to specify the type to use.
Error Code: 0
Call: INSERT INTO schema.table_name (item_id, item_path VALUES (?, ?)
bind => [2 parameters bound]
at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleInCallerTx(CMTTxInterceptor.java:138) [jboss-as-ejb3-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:228) [jboss-as-ejb3-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:317) [jboss-as-ejb3-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:214) [jboss-as-ejb3-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2]
at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) [jboss-as-ejb3-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2]
at org.jboss.as.ejb3.component.interceptors.ShutDownInterceptorFactory$1.processInvocation(ShutDownInterceptorFactory.java:64) [jboss-as-ejb3-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2]
at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59) [jboss-as-ejb3-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2]
at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50) [jboss-as-ee-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2]
at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:55) [jboss-as-ejb3-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2]
at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45) [jboss-as-ee-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2]
at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2]
at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165) [jboss-as-ee-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:182) [jboss-as-ee-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2]
at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2]
at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:72) [jboss-as-ee-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
Re: Cannot insert to 'path' field in Postgres db using EclipseLink [message #1270066 is a reply to message #1270048] Wed, 12 March 2014 13:07 Go to previous messageGo to next message
Eric Rizzo is currently offline Eric Rizzo
Messages: 2259
Registered: July 2009
Senior Member
Moving this to the Eclipselink forum.
Re: Cannot insert to 'path' field in Postgres db using EclipseLink [message #1270202 is a reply to message #1270066] Wed, 12 March 2014 17:11 Go to previous messageGo to next message
Daryl Foster is currently offline Daryl Foster
Messages: 3
Registered: March 2014
Junior Member
I've manually entered some data into table to see if I could successfully pull data from the table using EclipseLink. Now the convertDataValueToObjectValue method in my Converter throws the following exception:

java.lang.ClassCastException: org.postgresql.geometric.PGpath cannot be cast to org.postgresql.geometric.PGpath
Re: Cannot insert to 'path' field in Postgres db using EclipseLink [message #1271290 is a reply to message #1270202] Fri, 14 March 2014 18:54 Go to previous message
Daryl Foster is currently offline Daryl Foster
Messages: 3
Registered: March 2014
Junior Member
Turns out that it was a problem with how I had configured my application in JBoss. I had multiple copies of the jdbc driver jar, one in the deployed EAR file and one in the JBoss container. This was causing confusion because each jar was being loaded by a separate ClassLoader. Java identifies the class by its full name AND the ClassLoader.

Since I had already added the driver jar as a module to the JBoss server, I needed to remove the driver jar from the deployed EAR and set a dependency to the module that was in the JBoss server.
Previous Topic:How to Obtain Persistence Unit Name in DescriptorEventAdapter
Next Topic:Help migrating (JEE6 + jboss + hibernate + jds) resolved
Goto Forum:
  


Current Time: Wed Oct 01 08:11:53 GMT 2014

Powered by FUDForum. Page generated in 0.02793 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software