Java Mailing List Archive

http://www.gg3721.com/

Home » Hibernate Issues List »

[hibernate-issues] [Hibernate-JIRA] Commented: (ANN-654) Generated
SQL includes a
column named "null" when referencing a map entry by key and using
@LazyCollection(LazyCollectionOption.EXTRA)

Anupam M (JIRA)

2008-08-20


Author LoginPost Reply

  [ http://opensource.atlassian.com/projects/hibernate/browse/ANN-654?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_30952 ]

Ben Dave commented on ANN-654:
------------------------------

I have come across the same issue.
The problem arises when retrieving data from a map that is set to lazy="extra".
This only arises when lazy="extra"

The attached test case will fail, removing the lazy="extra" will fix the problem

> Generated SQL includes a column named "null" when referencing a map entry by key and using @LazyCollection(LazyCollectionOption.EXTRA)
> --------------------------------------------------------------------------------------------------------------------------------------
>
>           Key: ANN-654
>           URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-654
>         Project: Hibernate Annotations
>       Issue Type: Bug
>       Components: binder
>   Affects Versions: 3.2.0.ga
>      Environment: Oracle 10g, hibernate 3.2
>        Reporter: Paul Roe
>
> We have an Product entity with a map of RegionProduct by Region.
>   @MapKey(name="region")
>   @OneToMany(mappedBy="product", targetEntity= RegionProductImpl.class, fetch = FetchType.LAZY)
>   @LazyCollection(LazyCollectionOption.EXTRA)
>   private Map<Region, RegionProduct> regionProducts = new HashMap<Region, RegionProduct>();
> When accessing an element of the map by key, the SQL that is generated includes a "null" column in the WHERE condition.
>   where regionprod0_.PROD_ID=? and regionprod0_.null=?
> resulting in the stack trace
> org.hibernate.exception.SQLGrammarException: could not collection element by index
>  at org.hibernate.exception.SQLStateConverter.convert (SQLStateConverter.java:67)
>  at org.hibernate.exception.JDBCExceptionHelper.convert (JDBCExceptionHelper.java:43)
>  at org.hibernate.loader.Loader.loadEntity (Loader.java:1841)
>  at org.hibernate.loader.entity.CollectionElementLoader.loadElement (CollectionElementLoader.java:72)
>  at org.hibernate.persister.collection.OneToManyPersister.getElementByIndex (OneToManyPersister.java:360)
>  at org.hibernate.collection.AbstractPersistentCollection.readElementByIndex (AbstractPersistentCollection.java:158)
>  at org.hibernate.collection.PersistentMap.get (PersistentMap.java:146)
> Iterating over the collection works successfully, but populates the entire collection, which is what Extra-Lazy is meant to avoid.

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

   
_______________________________________________
hibernate-issues mailing list
hibernate-issues@(protected)
https://lists.jboss.org/mailman/listinfo/hibernate-issues
©2008 gg3721.com - Jax Systems, LLC, U.S.A.