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 7440319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:50:00+00:00 2026-05-29T10:50:00+00:00

I am trying to test some DAOs. I have Entity (and table) named Nomination

  • 0

I am trying to test some DAOs.

I have Entity (and table) named Nomination, it has some properties:

@Entity(name = "Nomination")
@Table(name = "NOMINATION")
@DiscriminatorColumn(name="CATEGORY_CODE", discriminatorType = DiscriminatorType.STRING, length = 1)

public class Nomination extends AuditableEntity {

@Id
@Column(name = "NOM_ID", insertable = true, updatable = true,
        nullable = false)
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;

@Transient
protected NominationType type = null;

@ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE})
@JoinColumn(name = "PERIOD_ID", referencedColumnName = "PERIOD_ID")
@Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE,
        org.hibernate.annotations.CascadeType.MERGE})
private NomPeriod period = null;

@ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE})
@JoinColumn(name = "CATEGORY_CODE", referencedColumnName = "CATEGORY_CODE")
@Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE,
        org.hibernate.annotations.CascadeType.MERGE})
private Category category = null;

@ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE})
@JoinColumn(name = "NOMINATOR_ID", referencedColumnName = "EMP_ID")
@Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE,
        org.hibernate.annotations.CascadeType.MERGE})
private Employee nominator = null;

@ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE})
@JoinColumn(name = "STATUS_ID", referencedColumnName = "STATUS_ID")
@Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE,
        org.hibernate.annotations.CascadeType.MERGE})
private Status status = null;

//more after this line

Now I have 4 different types of Nomination (idea, team, success, and coworker nominations) and 4 different tables(nomination, team_nom, idea_nom, success_nom). One (NOMINATION) has the common columns. This coincides with my first type of Nomination called CoworkerNom. There is no separate table for this one, since it only needs what’s listed in the NOMINATION table. The other 3 Nominations are: TeamNom, SuccessNom, and IdeaNom. These have their own tables as they have additional data, and so they also have their own Entities. For example:

@Entity(name = "IdeaNom")
@Table(name = "IDEA_NOM")
@DiscriminatorValue("I")

public class IdeaNom extends Nomination {

@Column(name = "PURPOSE_INC", insertable = true, updatable = true,
        nullable = true)
private Boolean purposeIncrease;

@Column(name = "PURPOSE_SIMPLIFY", insertable = true, updatable = true,
        nullable = true)
private Boolean purposeSimplify;

//more after this line

This structure applies to SuccessNom and TeamNom.

I am having problems understanding how to do this, but for now I have done some DAOs and am trying to test them out. However I am getting the following error:

Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: 

com.dev.test.data.entity.SuccessNom column: CATEGORY_CODE (should be mapped with insert="false" update="false")
    at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:676)
    at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:698)
    at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:720)
    at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:474)
    at org.hibernate.mapping.SingleTableSubclass.validate(SingleTableSubclass.java:65)
    at org.hibernate.cfg.Configuration.validate(Configuration.java:1362)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1865)
    at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:860)
    at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:779)
    at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1479)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
    ... 54 more

First of all, CATEGORY_CODE is the discriminator… but it should be able to be writable. Hopefully you guys will be able to help me out once more.

Edit: this is my schema

Schema

  • 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-05-29T10:50:01+00:00Added an answer on May 29, 2026 at 10:50 am

    If you need to map the discriminator column, map it with insert="false" update="false". Hibernate considers it declared once, and it is not writable – it can only be managed by hibernate. Also, it’s a bit odd to join on that column.

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

Sidebar

Related Questions

Im trying to get some checkbox with a specific name document.getElementsByName(test); Unfortunatley i cant
I am currently trying to test some code I have in a web application
I am trying to use Qunit to test some code, but I have some
I'm trying to unit test some code which utilises a library which has a
I have a Riak Search node running and am trying out some test queries
I am trying to do some test with jMeter. I have CSV file with
I am trying to test some of these code here http://ha.ckers.org/xss.html on my code.
I am trying to test some exceptions in my project and one of the
I am trying to learn unit testing. I am trying to unit test some
I am still trying to test my WinForm application, however some of the testing

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.