[Hibernate-JIRA] Commented: (HHH-1268) Unidirection OneToMany causes duplicate key entry violation when removing from list
by Some One (JIRA)
[ https://hibernate.onjira.com/browse/HHH-1268?page=com.atlassian.jira.plug... ]
Some One commented on HHH-1268:
-------------------------------
1) Any update on this? It surprises me that there are still issues for basic relationships such as this.
2) @ Kevin Jordan
How did you remove the unique constraint? Directly in the db? Is there a way to do it in the annotations? I'm generating the db schema from the annotations and would like to avoid any additional custom steps.
Thanks everyone.
> Unidirection OneToMany causes duplicate key entry violation when removing from list
> -----------------------------------------------------------------------------------
>
> Key: HHH-1268
> URL: https://hibernate.onjira.com/browse/HHH-1268
> Project: Hibernate ORM
> Issue Type: Bug
> Affects Versions: 3.1, 3.5.6, 3.6.0
> Environment: 3.1 final
> MySql 4.1.14 using MYISAM tables
> Reporter: Rex Madden
> Assignee: Gail Badner
> Fix For: 3.2.x, 3.3.x
>
> Attachments: possible_solution.patch, src.zip
>
>
> Simple OneToMany parent/child relationship using the default table structure (2 tables and a join table)
> Add 3 children to the parent. Flush. Remove the first child. Flush throws error:
> Exception in thread "main" org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
> at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:69)
> at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
> at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:202)
> at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:230)
> at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:143)
> at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
> at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
> at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:980)
> at UnidirectionalOneToManyRemoveFromListBug.main(UnidirectionalOneToManyRemoveFromListBug.java:27)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at com.intellij.rt.execution.application.AppMain.main(AppMain.java:86)
> Caused by: java.sql.BatchUpdateException: Duplicate key or integrity constraint violation, message from server: "Duplicate entry '5' for key 2"
> at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1461)
> at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
> at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
> ... 11 more
> The problem is that there is a unique key on the relationship table that gets violated. The session removes the last row in the relationship table, then attempts to rewrite the child_id's. It fails since there is a uniqueness constraint on that column.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 8 months
[Hibernate-JIRA] Created: (HHH-7303) inner join problem when use constructor in JPQL
by deng hui (JIRA)
inner join problem when use constructor in JPQL
-----------------------------------------------
Key: HHH-7303
URL: https://hibernate.onjira.com/browse/HHH-7303
Project: Hibernate ORM
Issue Type: Bug
Components: entity-manager
Affects Versions: 4.1.0
Environment: Spring 3.1.1
Reporter: deng hui
I have 2 domain classes:
'Process' and 'Account' they are keeping Many-To-One relationship which means:
Process may belongs to one Account or not belongs to any Account,
and one Account can own multi-Process.
a query in Spring Framework like
{code}
public interface ProcessRepository extends CrudRepository<Process, Long> {
@Query("select distinct new Process(p.id, p.name,p.diversity,p.version,p.account,p.description) from Process p right join p.account where p.name like ?1 and p.state.id=1")
List<Process> findProcessByName(String name);
}
{code}
when app is running i got:
{code}
Hibernate: select distinct process0_.id as col_0_0_, process0_.name as col_1_0_, process0_.diversity as col_2_0_, process0_.version as col_3_0_, process0_.account_id as col_4_0_, process0_.description as col_5_0_ from Process process0_ right outer join Account account1_ on process0_.account_id=account1_.id inner join Account account2_ on process0_.account_id=account2_.id where (process0_.name like ?) and process0_.state_id=1
{code}
no record retrieved.
if I change to
{code}
public interface ProcessRepository extends CrudRepository<Process, Long> {
@Query("select distinct new Process(p.id, p.name,p.diversity,p.version,p.account,p.description) from Process p where p.name like ?1 and p.state.id=1")
List<Process> findProcessByName(String name);
}
{code}
then I got:
{code}
Hibernate: select distinct process0_.id as col_0_0_, process0_.name as col_1_0_, process0_.diversity as col_2_0_, process0_.version as col_3_0_, process0_.account_id as col_4_0_, process0_.description as col_5_0_ from Process process0_ inner join Account account2_ on process0_.account_id=account2_.id where (process0_.name like ?) and process0_.state_id=1
{code}
this(inner join) is also not I want since account may be null in process object.
is this a bug?
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 8 months
[Hibernate-JIRA] Created: (HSEARCH-1107) WorkDoneOnEntitiesTest test times out on Sybase15
by Sanne Grinovero (JIRA)
WorkDoneOnEntitiesTest test times out on Sybase15
-------------------------------------------------
Key: HSEARCH-1107
URL: https://hibernate.onjira.com/browse/HSEARCH-1107
Project: Hibernate Search
Issue Type: Task
Affects Versions: 4.1.0.Final
Reporter: Sanne Grinovero
>From the matrix build on Jenkins, this is consistently happening on the jobs running sybase155
{quote}
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.423 sec
Running org.hibernate.search.test.embedded.depth.WorkDoneOnEntitiesTest
Build timed out (after 180 minutes). Marking the build as failed.
Destroying 1 processes
Destroying process..
{quote}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 8 months
[Hibernate-JIRA] Created: (HHH-4030) Implement support for native recursive query functionality of popular DBMSes
by David Cracauer (JIRA)
Implement support for native recursive query functionality of popular DBMSes
----------------------------------------------------------------------------
Key: HHH-4030
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4030
Project: Hibernate Core
Issue Type: New Feature
Components: core, query-hql, query-sql
Environment: Hibernate 3.3.2, MSSQL
Reporter: David Cracauer
We have a couple of areas in our system where need to load tree structures from our database. These trees can be very deep (often 20+ levels). SQL Server 2005 introduced Common Table Expressions, a kind of in-line view that can be used recursively.
These allow us to quickly get a result set like this:
id, label, parentId
1, foo, null
2, foo2, 1
3, foo3, 2
4, foo4, 2
5, foo5, 4
6, foo6, 1
>From a tree like this:
[1, foo]
|
| -[2, foo2]
| | - [3, foo3]
| | - [4, foo4]
| | - [5, foo5]
|- [6, foo6]
using a query like this (not tested):
with MyCTE(
id,
label,
parentId)
as
( select n.id, n.label, n.parentid
from Node n
UNION ALL
select c.id, c.label, c.parentId
from MyCTE c
inner join Node n on n.id=c.parentId)
select * from MyCTE
It happens many times more quickly than we've been able to load the graphs with Hibernate, even using batching etc.
We've tried using hibernate's built in native sql support without success. The alias injection breaks the Common Table Expression definition ( with MyCTE ), as it is a view definition and doesn't allow for the 'id as id_276' syntax, rather requiring just a column name.
I know that there are several other major DBMSes that support recursive querying now. Is there a way to have support for this functionality in hibernate core?
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 8 months