pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Cannot insert to 'path' field using EclipseLink
6+ messages / 4 participants
[nested] [flat]

* Cannot insert to 'path' field using EclipseLink
@ 2014-03-12 12:37  Daryl Foster <daryl.foster@oncenter.com>
  0 siblings, 2 replies; 6+ messages in thread

From: Daryl Foster @ 2014-03-12 12:37 UTC (permalink / raw)
  To: pgsql-general@postgresql.org; pgsql-jdbc; pgsql-novice@postgresql.org

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]
...
-- 

Sincerely,

*Daryl Foster*

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Cannot insert to 'path' field using EclipseLink
@ 2014-03-12 13:18  Sehrope Sarkuni <sehrope@jackdb.com>
  parent: Daryl Foster <daryl.foster@oncenter.com>
  1 sibling, 0 replies; 6+ messages in thread

From: Sehrope Sarkuni @ 2014-03-12 13:18 UTC (permalink / raw)
  To: Daryl Foster <daryl.foster@oncenter.com>; +Cc: pgsql-jdbc

Daryl-

I'm not too familiar with EclipseLink but looks like the problem is
there and not with the PG JDBC driver.

If you use the JDBC driver directly and call setObject(...) to bind
the PGpath parameter, it works fine for both null and not-null values
(tested with the latest 9.3 JDBC driver against a 9.3 database):

  Table:
    CREATE TABLE path_sample (name text, item_path path);

  Java:
    Connection conn = ...
    String sql = "INSERT INTO path_sample (name, item_path) VALUES (?, ?)";
    PreparedStatement stmt = conn.prepareStatement(sql);
    // Insert a not null point:
    stmt.setString(1, "foobar");
    stmt.setObject(2, new PGpath(new PGpoint[] {new PGpoint(0, 0), new
PGpoint(1, 1)}, false));
    stmt.execute();
    // Insert a null point:
    stmt.setString(1, "null point");
    stmt.setObject(2, null);
    stmt.execute();

My guess is that EclipseLink isn't calling setObject(...). I suggest
you enable more debug logs for EclipseLink to see exactly what it's
doing and how it's binding the statement parameters. Your converter is
probably not being used properly.

Regards,
Sehrope Sarkuni
Founder & CEO | JackDB, Inc. | http://www.jackdb.com/


-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Cannot insert to 'path' field using EclipseLink
@ 2014-03-12 17:12  Daryl Foster <daryl.foster@oncenter.com>
  parent: Daryl Foster <daryl.foster@oncenter.com>
  1 sibling, 2 replies; 6+ messages in thread

From: Daryl Foster @ 2014-03-12 17:12 UTC (permalink / raw)
  To: pgsql-general@postgresql.org; pgsql-jdbc; pgsql-novice@postgresql.org

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


On Wed, Mar 12, 2014 at 7:37 AM, Daryl Foster <daryl.foster@oncenter.com>wrote:

> 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]
> ...
> --
>
> Sincerely,
>
> *Daryl Foster*
>



-- 

Sincerely,

*Daryl Foster*
*Software Engineer*

On Center Software, Inc.

*P:* 281.210.0177
*F:* 281.297.9001
*W:* *www.oncenter.com <http://www.oncenter.com/>*

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Cannot insert to 'path' field using EclipseLink
@ 2014-03-12 17:40  Steven Schlansker <stevenschlansker@gmail.com>
  parent: Daryl Foster <daryl.foster@oncenter.com>
  1 sibling, 0 replies; 6+ messages in thread

From: Steven Schlansker @ 2014-03-12 17:40 UTC (permalink / raw)
  To: Daryl Foster <daryl.foster@oncenter.com>; +Cc: pgsql-general@postgresql.org <pgsql-general@postgresql.org>; pgsql-jdbc; pgsql-novice@postgresql.org <pgsql-novice@postgresql.org>



> On Mar 12, 2014, at 10:12 AM, Daryl Foster <daryl.foster@oncenter.com> wrote:
> 
> java.lang.ClassCastException: org.postgresql.geometric.PGpath cannot be cast to org.postgresql.geometric.PGpath
> 

That's a sure sign of ClassLoader confusion. Make sure there is only one copy of the driver jar in your application or the JBoss container, but never both. 

> 
>> On Wed, Mar 12, 2014 at 7:37 AM, Daryl Foster <daryl.foster@oncenter.com> wrote:
>> 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]
>> ...
>> -- 
>> Sincerely,
>> Daryl Foster
> 
> 
> 
> -- 
> Sincerely,
> Daryl Foster
> Software Engineer
> On Center Software, Inc.
> 
> P: 281.210.0177
> F: 281.297.9001
> W: www.oncenter.com

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Cannot insert to 'path' field using EclipseLink
@ 2014-03-12 18:23  Rob Sargent <robjsargent@gmail.com>
  parent: Daryl Foster <daryl.foster@oncenter.com>
  1 sibling, 1 reply; 6+ messages in thread

From: Rob Sargent @ 2014-03-12 18:23 UTC (permalink / raw)
  To: pgsql-general@postgresql.org

On 03/12/2014 11:12 AM, Daryl Foster wrote:
> 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
>
recompile everything with the same version of java? double check 
dependencies?


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Cannot insert to 'path' field using EclipseLink
@ 2014-03-14 16:58  Daryl Foster <daryl.foster@oncenter.com>
  parent: Rob Sargent <robjsargent@gmail.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Daryl Foster @ 2014-03-14 16:58 UTC (permalink / raw)
  To: Rob Sargent <robjsargent@gmail.com>; +Cc: pgsql-general@postgresql.org

Turns out that it was a JBoss problem. I had to remove the driver jar from
the deployed EAR file and set a dependency to the module in the JBoss
server.

This link has the details: https://community.jboss.org/message/862434

Thanks for pointing me in the right direction.


On Wed, Mar 12, 2014 at 1:23 PM, Rob Sargent <robjsargent@gmail.com> wrote:

> On 03/12/2014 11:12 AM, Daryl Foster wrote:
>
>> 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
>>
>>  recompile everything with the same version of java? double check
> dependencies?
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>



-- 

Sincerely,

*Daryl Foster*
*Software Engineer*

On Center Software, Inc.

*P:* 281.210.0177
*F:* 281.297.9001
*W:* *www.oncenter.com <http://www.oncenter.com/>*

^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2014-03-14 16:58 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-03-12 12:37 Cannot insert to 'path' field using EclipseLink Daryl Foster <daryl.foster@oncenter.com>
2014-03-12 13:18 ` Sehrope Sarkuni <sehrope@jackdb.com>
2014-03-12 17:12 ` Daryl Foster <daryl.foster@oncenter.com>
2014-03-12 17:40   ` Steven Schlansker <stevenschlansker@gmail.com>
2014-03-12 18:23   ` Rob Sargent <robjsargent@gmail.com>
2014-03-14 16:58     ` Daryl Foster <daryl.foster@oncenter.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox