[Hibernate-JIRA] Created: (HHH-3197) subquery is not valid SQL when select type is same as parent sql select type
by Nicolai Marck Ødum (JIRA)
subquery is not valid SQL when select type is same as parent sql select type
----------------------------------------------------------------------------
Key: HHH-3197
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3197
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.2.6
Environment: Java 1.5.0_14
JBoss 4.2.2.GA (Hibernate 3.2.1) - I have also tried with Hibernate 3.2.6.ga, hibernate-annotations-3.3.1.GA and hibernate-entitymanager-3.3.2.GA with same result.
PostgreSQL 8.3.0
WindowsXP
Reporter: Nicolai Marck Ødum
The following ejb3 QL:
"Delete FROM Notification noti WHERE noti NOT IN (SELECT subNoti.notifications FROM SubscriberNotification subNoti)"
Result in the following sql
"delete from Notification where id not in (select . from SubscriberNotification subscriber1_, SubscriberNotification_Notification notificati2_, Notification notificati3_ where subscriber1_.id=notificati2_.SubscriberNotification_id and notificati2_.notifications_id=notificati3_.id)"
notice the "select . from" in the subquery
if I alter the sql to be
"delete from Notification where id not in (select notificati3_.id from SubscriberNotification subscriber1_, SubscriberNotification_Notification notificati2_, Notification notificati3_ where subscriber1_.id=notificati2_.SubscriberNotification_id and notificati2_.notifications_id=notificati3_.id)"
I have not been able to create a workaround.
--
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
15 years, 5 months
[Hibernate-JIRA] Created: (HHH-3645) Bug with list when rearranging - treat it as urgent
by leela (JIRA)
Bug with list when rearranging - treat it as urgent
---------------------------------------------------
Key: HHH-3645
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3645
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.1
Reporter: leela
Class A has a child list specifying an association to another class B.
Table A
AId
Table B
BId
Table C(Association Table with 3 columns)
AId(Id of Table A)
BId(Id of Table B)
SeqNo
OtherColumn1
OtherColumn2
When I rearrange the child list, obviously the index will be changing.
Initially the table C was mapped like this before rearranging.
A1 B1 0 XX YY
A1 B2 1 YY ZZ
A1 B3 2 ZZ XX
After rearranging the java list contains :
A1 B2 0 XX YY
A1 B1 1 XX YY
A2 B3 2 ZZ XX
But when this list is getting persisted, hibernate is trying to do an update by seq no
update tablec set table Bid = B2 where Aid = A1 and SeqNo = 0
It fails to persit because since we had set a unique composite index on AId and BId.
That means hibernate was trying to persist like this, that caused the failures.
A1 B2 0
A1 B2 1
A1 B3 2
Here is my hibernate mapping in classA mapping file.
<list name="assocList"
lazy="true"
access="field"
cascade="save-update"
outer-join="false"
table="tablec">
<key column="aid" not-null="true" unique="false"/>
<list-index column="seqno"/>
<composite-element class="ClassC">
<many-to-one name="ClassB" column="bid" lazy="proxy"/>
<property ..../>
<property ..../>
</composite-element>
</list>
Should not hibernate supposed to delete and reinsert the child elements? Then what is the solution for this? Is not this a bug?
--
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
15 years, 5 months
[Hibernate-JIRA] Created: (HHH-3638) Ability to use Criteria with Queries
by Adriano dos Santos Fernandes (JIRA)
Ability to use Criteria with Queries
------------------------------------
Key: HHH-3638
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3638
Project: Hibernate Core
Issue Type: New Feature
Components: core, query-criteria, query-hql, query-sql
Reporter: Adriano dos Santos Fernandes
I done it, for my needs, using internal classes. It would be very great to have this nativelly on Hibernate.
Query createQueryByExample(Query query, Entidade entity)
{
SessionImpl session = (SessionImpl) entityManager.getDelegate();
Class<?> entityClass = entity.getClass();
CriteriaImpl criteria = (CriteriaImpl) session.createCriteria(entityClass);
CriteriaQueryTranslator criteriaQuery = new CriteriaQueryTranslator(
session.getFactory(), criteria, entityClass.getName(), "z");
Example example = Example.create(entity)
.enableLike(MatchMode.START)
.excludeZeroes();
criteria.add(example);
String newSql = "select * from (" +
((HibernateQuery) query).getHibernateQuery().getQueryString() +
") z";
Object[] params = criteriaQuery.getQueryParameters().getPositionalParameterValues();
if (params.length > 0)
{
String newWhere = example.toSqlString(criteria, criteriaQuery);
newSql += "\nwhere " + newWhere;
query = entityManager.createNativeQuery(newSql, entityClass);
int n = 0;
for (Object param : params)
query.setParameter(++n, param);
}
return query;
}
--
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
15 years, 5 months