[hibernate-dev] Upgrading Hibernate Causes null index column for collection error for List

Gail Badner gbadner at redhat.com
Mon Feb 18 19:19:33 EST 2019


Hi Amit,

This mailing list is for people working on Hibernate development.

If you think you have found a bug, then please create a jira issue (
https://hibernate.atlassian.net/) and attach a test case that reproduces
your issue.

Regards,
Gail

On Fri, Feb 15, 2019 at 6:05 AM Amit Shah <amits.84 at gmail.com> wrote:

> We are trying to upgrade hibernate from version 4.3.5 to 5.4.0. With this
> the jpa version also changes from hibernate-jpa-2.1 to jpa-2.2. After the
> upgrade we get the following error when using the List<> collection with
> @OrderColumn
>
> "javax.persistence.PersistenceException: org.hibernate.HibernateException:
> null index column for collection"
>
> It is a unidirectional one-to-mapping with following annotations
>
> @Entity at Table(name = "DS_GENERIC")@PrimaryKeyJoinColumn(name =
> "DSG_DS_ID")public class GenericConnection extends
> DataSourceConnection {
>
>     @OneToMany(cascade = ALL, orphanRemoval = true, fetch =
> FetchType.EAGER)
>     @JoinColumn(name = "DSC_DS_ID", nullable = false)
>     @OrderColumn(name = "DSC_ORDER", updatable = false, insertable = false)
>     List<Credentials> credentials = new ArrayList<>();
> }
> @Entity at Table(name = "DS_CREDENTIALS")public class Credentials {
>
>     @Id
>     @GeneratedValue(generator = "uid-generator")
>     @Column(name = "DSC_ID", updatable = false)
>     private Long id;
>
>     //...}
>
> The below test code fails
>
> //construct the connection object with credentials
> entityManager.persist(connection);
> entityManager.find(DataSourceConnection.class, id); //this call fails
> with the above error
>
> Note that this code worked fine with hibernate 4.3.5 and one workaround
> that also works is converting List to Set as below
>
> @OneToMany(cascade = ALL, orphanRemoval = true, fetch =
> FetchType.EAGER)@JoinColumn(name = "DSC_DS_ID", nullable =
> false)@OrderBy("DSC_ID")Set<Credentials> credentials = new
> HashSet<>();
>
> I do not understand the root cause of this failure. Any inputs would be
> appreciated.
>
> Thanks.
>
> P.S - I have posted this query on stackoverflow too
> <
> https://stackoverflow.com/questions/54686603/upgrading-hibernate-causes-null-index-column-for-collection-error-for-list
> >
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>


More information about the hibernate-dev mailing list