[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-1657) hql update generate wrong sql with joined subclass hierarcy

Tamir Solomon (JIRA) noreply at atlassian.com
Thu Jul 12 09:00:52 EDT 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1657?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_27465 ] 

Tamir Solomon commented on HHH-1657:
------------------------------------

Hi.
i have the same issue as David 
the update query is :
update ADSocket remoteSocket set remoteSocket.twinSocket = (select localSocket from ADSocket localSocket " +
					"where localSocket.isLocalSocket=true and " +
					"(remoteSocket.ip!=null and localSocket.ip=remoteSocket.ip and " +
					"remoteSocket.port=localSocket.port " +
					"and remoteSocket.isServerSocket=localSocket.isServerSocket)) 

where as the generated sql is :
Hibernate: insert into #AD_SOCKET select adsocket0_.SO_SOCKET_ID as SO_SOCKET_ID from AD_SOCKET adsocket0_ inner join AD_ENTITY adsocket0_1_ on adsocket0_.SO_SOCKET_ID=adsocket0_1_.EN_ID where ( EN_IS_DELETED is null or EN_IS_DELETED = 0) and SO_DETECTION_SERVER_ID=? and SO_IS_LOCAL=0
Hibernate: update AD_SOCKET set SO_TWIN_SOCKET=(select SO_SOCKET_ID from AD_SOCKET adsocket1_ inner join AD_ENTITY adsocket1_1_ on adsocket1_.SO_SOCKET_ID=adsocket1_1_.EN_ID where ( adsocket1_1_.EN_IS_DELETED is null or adsocket1_1_.EN_IS_DELETED = 0) and adsocket1_.SO_IS_LOCAL=1 and (adsocket0_.SO_IP is not null) and adsocket1_.SO_IP=adsocket0_.SO_IP and adsocket0_.SO_PORT=adsocket1_.SO_PORT and adsocket0_.SO_IS_SERVER_SOCKET=adsocket1_.SO_IS_SERVER_SOCKET) where (SO_SOCKET_ID) IN (select SO_SOCKET_ID from #AD_SOCKET)
Hibernate: insert into #AD_SOCKET select adsocket0_.SO_SOCKET_ID as SO_SOCKET_ID from AD_SOCKET adsocket0_ inner join AD_ENTITY adsocket0_1_ on adsocket0_.SO_SOCKET_ID=adsocket0_1_.EN_ID where ( EN_IS_DELETED is null or EN_IS_DELETED = 0)
Hibernate: update AD_SOCKET set SO_TWIN_SOCKET=(select SO_SOCKET_ID from AD_SOCKET adsocket1_ inner join AD_ENTITY adsocket1_1_ on adsocket1_.SO_SOCKET_ID=adsocket1_1_.EN_ID where ( adsocket1_1_.EN_IS_DELETED is null or adsocket1_1_.EN_IS_DELETED = 0) and adsocket1_.SO_IS_LOCAL=1 and (adsocket0_.SO_IP is not null) and adsocket1_.SO_IP=adsocket0_.SO_IP and adsocket0_.SO_PORT=adsocket1_.SO_PORT and adsocket0_.SO_IS_SERVER_SOCKET=adsocket1_.SO_IS_SERVER_SOCKET) where (SO_SOCKET_ID) IN (select SO_SOCKET_ID from #AD_SOCKET)

and the error from the DB is (on the last update statement):
com.sybase.jdbc3.jdbc.SybSQLException: ASA Error -142: Correlation name 'adsocket0_' not found

Anyone ??
T.


> hql update generate wrong sql with joined subclass hierarcy
> -----------------------------------------------------------
>
>                 Key: HHH-1657
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1657
>             Project: Hibernate3
>          Issue Type: Bug
>          Components: query-hql
>         Environment: Hibernate 3.2.0cr1, Hibernate 3.1.3
>            Reporter: Alexey Romanchuk
>            Priority: Critical
>
> Let suppose that we have two joined subclass entities: Parent (id PK) and Child (id PK) that mapped with joined subclass method.
> When I try to update Child by id with hql:
> update Child c set c.field = 'value' where c.id = 1234
> hibernate generates joined tables like 
> insert into HT_parent select child0_.id as id from child child0_ inner join parent child0_1_ on child0_.id=child0_1_.id  wher id in = 1234
> look at last condition. hibernate use id WITH OUT tables alias that cause sql exception: column reference "id" is ambiguous

-- 
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.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list