Re: BUG #4586: Supporting of Binary instead Bytea for Primary Keys

Поиск
Список
Период
Сортировка
От Miroslav Nachev
Тема Re: BUG #4586: Supporting of Binary instead Bytea for Primary Keys
Дата
Msg-id 494984A6.5000200@space-comm.com
обсуждение исходный текст
Ответ на Re: BUG #4586: Supporting of Binary instead Bytea for Primary Keys  (Kris Jurka <books@ejurka.com>)
Список pgsql-bugs
Yes, you are right. With the correct code:
    public static void main(String[] args) {
        UUID uuid = UUID.randomUUID();
        TestTable1 testTable = new TestTable1(uuid);
        persist(testTable);
    }

the exception is:
Hibernate: insert into test_db.public.test_table_1 (description, my_id)
values (?, ?)
2008-12-18 0:58:39 org.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 0, SQLState: null
2008-12-18 0:58:39 org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: Batch entry 0 insert into test_db.public.test_table_1
(description, my_id) values (NULL, '<stream of 80 bytes>') was aborted.
Call getNextException to see the cause.
2008-12-18 0:58:39 org.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 0, SQLState: 42804
2008-12-18 0:58:39 org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: ERROR: column "my_id" is of type uuid but expression is of type
bytea
  Hint: You will need to rewrite or cast the expression.
  Position: 55
2008-12-18 0:58:39 org.hibernate.event.def.AbstractFlushingEventListener
performExecutions
SEVERE: Could not synchronize database state with session
org.hibernate.exception.SQLGrammarException: Could not execute JDBC
batch update
        at
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
        at
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
        at
org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
        at
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:237)
        at
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
        at
org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
        at
org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
        at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
        at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
        at
org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
        at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:54)
        at psqluuidtest.Main.persist(Main.java:34)
        at psqluuidtest.Main.main(Main.java:25)
Caused by: java.sql.BatchUpdateException: Batch entry 0 insert into
test_db.public.test_table_1 (description, my_id) values (NULL, '<stream
of 80 bytes>') was aborted.  Call getNextException to see the cause.
        at
org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2556)
        at
org.postgresql.core.v3.QueryExecutorImpl$1.handleError(QueryExecutorImpl.java:395)
        at
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1348)
        at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:343)
        at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2693)
        at
org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
        at
org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
        ... 10 more
javax.persistence.RollbackException: Error while commiting the transaction
        at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:71)
        at psqluuidtest.Main.persist(Main.java:34)
        at psqluuidtest.Main.main(Main.java:25)
Caused by: org.hibernate.exception.SQLGrammarException: Could not
execute JDBC batch update
        at
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
        at
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
        at
org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
        at
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:237)
        at
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
        at
org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
        at
org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
        at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
        at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
        at
org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
        at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:54)
        ... 2 more
Caused by: java.sql.BatchUpdateException: Batch entry 0 insert into
test_db.public.test_table_1 (description, my_id) values (NULL, '<stream
of 80 bytes>') was aborted.  Call getNextException to see the cause.
        at
org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2556)
        at
org.postgresql.core.v3.QueryExecutorImpl$1.handleError(QueryExecutorImpl.java:395)
        at
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1348)
        at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:343)
        at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2693)
        at
org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
        at
org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
        ... 10 more
Exception in thread "main" java.lang.IllegalStateException: Transaction
not active
        at
org.hibernate.ejb.TransactionImpl.rollback(TransactionImpl.java:82)
        at psqluuidtest.Main.persist(Main.java:37)
        at psqluuidtest.Main.main(Main.java:25)



Miro.


Kris Jurka wrote:
> Miroslav Nachev wrote:
>> I try to use it but I have the following exception:
>>
>> java.lang.IllegalArgumentException: Unknown entity: java.util.UUID
>>         at
>> org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:223)
>>
>>         at psqluuidtest.Main.persist(Main.java:33)
>>         at psqluuidtest.Main.main(Main..java:25)
>>
>
> Surely you want to persist a TestTable1 instance, not the uuid itself.
>
> Kris Jurka
>

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Miroslav Nachev
Дата:
Сообщение: Re: BUG #4586: Supporting of Binary instead Bytea for Primary Keys
Следующее
От: Miroslav Nachev
Дата:
Сообщение: Re: BUG #4586: Supporting of Binary instead Bytea for Primary Keys