Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8240921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:39:33+00:00 2026-06-07T20:39:33+00:00

I am having difficulties mapping a list in hibernate. I would like to know

  • 0

I am having difficulties mapping a list in hibernate. I would like to know what you think of my classes, mapping and database scheme. If everything is right, I would appreciate some help on the thrown exception. Thanks in advance !

I have the following classes :

public class AuditEntry {

    private long id;
    private String typeLigne;
    private String famille;
    private String user;
    private String libelle ;
    private String processName;
    private String caseId;
    private Date dateCreation = null;
    private List<AuditEntryStringMap> libelles;

    /* Getters and setters generated automatically... */
}

public class AuditEntryStringMap {

    private long id ;
    private String key ;
    private String value ;

    public AuditEntryStringMap(String key, String value) {
        this.key = key ;
        this.value = value ;
    }
        /* Getters and setters generated automatically... */
}

My hbm files are the following :

<class name="AuditEntryStringMap" table="AUDIT_I18N">

        <cache usage="read-write" include="all" />
        <id name="id" type="long">
            <column name="AUDIT_I18N_ID"></column>
            <generator class="sequence" >
            <param name="sequence">AUDIT_I18N_SEQ</param>
            </generator>
        </id>

        <property name="key" column="KEY_" />
        <property name="value" column="VALUE_"/>

</class>
<class name="AuditEntry" table="AUDIT">

        <cache usage="read-write" include="all" />
        <id name="id" type="long">
            <column name="AUDIT_ID"></column>
            <generator class="sequence" >
            <param name="sequence">AUDIT_SEQ</param>
            </generator>
        </id>

        <property name="typeLigne" column="TYPELIGNE" />

        <property name="libelle" column="LIBELLE" />

        <property name="user" column="USERNAME" />

        <property name="processName" column="PROCESSNAME" />

        <property name="caseId" column="CASE_ID" />

        <property name="dateCreation" insert="false" update="false">
            <column name="DCRE" sql-type="date" default="sysdate"></column>
        </property>

        <list name="libelles" table="AUDIT_I18N"> 
            <key> 
                <column name="FK_AUDIT_ID" sql-type="number(19,0)" /> 
            </key> 
            <index type="string" column="KEY_" /> 
            <element type="string" column="VALUE_" /> 
        </list>
    </class>

Finally, my sql script is the following :

create sequence AUDIT_SEQ;
create sequence AUDIT_I18N_SEQ;

create table AUDIT (
    AUDIT_ID     number(19,0) not null,  
    TYPELIGNE    varchar2(255 char), 
    LIBELLE      varchar2(255 char),
    USERNAME     varchar2(255 char), 
    CASE_ID      varchar2(255 char),
    PROCESSNAME  varchar2(255 char), 
    DCRE          date default sysdate, 
    primary key (AUDIT_ID));

create table AUDIT_I18N (
    AUDIT_I18N_ID     number(19,0) not null, 
    KEY_              varchar2(255 char), 
    VALUE_            varchar2(255 char), 
    FK_AUDIT_ID       number(19, 0), 
    primary key (AUDIT_I18N_ID)) 

ALTER TABLE AUDIT_I18N add constraint FK_AUDIT_I18N foreign key (FK_AUDIT_ID) references AUDIT;

Hibernate generates the following queries before casting an exception on commit :

Hibernate: select AUDIT_SEQ.nextval from dual
Hibernate: insert into AUDIT (TYPELIGNE, LIBELLE, USERNAME, PROCESSNAME, CASE_ID, AUDIT_ID) values (?, ?, ?, ?, ?, ?)
Hibernate: insert into AUDIT_I18N (FK_AUDIT_ID, KEY_, VALUE_) values (?, ?, ?)

The exception :

com.bpm.domain.AuditEntryStringMap cannot be cast to java.lang.String

Which occurs when GenericDaoHibernate.save(T entity) is called.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T20:39:35+00:00Added an answer on June 7, 2026 at 8:39 pm

    Solved the problem using a set instead of a list… And this in the mapping :

    <set name="libelles" lazy="extra" cascade="all-delete-orphan">
                 <cache usage="read-write" include="all" />
                 <key column="FK_AUDIT_ID"/>
                 <one-to-many class="AuditEntryStringMap" />
    </set>
    

    Also, my hbm for AuditEntryStringMap was not referenced in the hibernate.cfg.xml. But this alone did not solve the problem with the list tag.

    Half a resolution so… Would appreciate the full resolution if someone knows why it didn’t work with a list.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having difficulties when trying to insert files into a SQL Server database.
I am having difficulties because of the database structure on a game website similar
I am having difficulties understanding AsyncTask, even after reading everything about it on Developer.Android.
Im having difficulties trying to get a connection to my sqlserver database. The database
I'm having difficulties returning a typed List. For some reason it is returned as
having difficulties because of my noobness, again. I dont know if I am doing
I'm studying computer science and am brushing up on database systems. I'm having difficulties
I'm having difficulties to display data from mysql database to PHP generated table. Interesting
I am having difficulties achieving Css 100% so my website can look right in
I am having difficulties grasping the concept of echoing a variable from a database

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.