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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:43:44+00:00 2026-05-26T07:43:44+00:00

I am trying to implement a simple join operation with my two tables ,using

  • 0

I am trying to implement a simple join operation with my two tables ,using hibernate 3 annotaions with spring3 mvc.

I have two tables:

Employee

CREATE TABLE IF NOT EXISTS `employee` (`enter code here`
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(100) NOT NULL,
  `address1` varchar(100) NOT NULL,
  `address2` varchar(100) NOT NULL,
  `created_at` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB

Salary

CREATE TABLE IF NOT EXISTS `salary` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `employee_id` int(11) NOT NULL,
  `basic_pay` int(5) NOT NULL,
  `take_home` int(5) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `employee_id` (`employee_id`)
) ENGINE=InnoDB

I have created two annotated modal classes:

Employee.java

@Entity
@Table(name = "employee", catalog = "employee")
public class Employee implements java.io.Serializable {

    private Integer id;
    private String name;
    private String address1;
    private String address2;
    private Date createdAt;
    private Set salaries = new HashSet(0);

    public Employee() {
    }

    public Employee(String name, String address1, String address2,
            Date createdAt) {
        this.name = name;
        this.address1 = address1;
        this.address2 = address2;
        this.createdAt = createdAt;
    }

    public Employee(String name, String address1, String address2,
            Date createdAt, Set salaries) {
        this.name = name;
        this.address1 = address1;
        this.address2 = address2;
        this.createdAt = createdAt;
        this.salaries = salaries;
    }

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "id", unique = true, nullable = false)
    public Integer getId() {
        return this.id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Column(name = "name", nullable = false, length = 100)
    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name = "address1", nullable = false, length = 100)
    public String getAddress1() {
        return this.address1;
    }

    public void setAddress1(String address1) {
        this.address1 = address1;
    }

    @Column(name = "address2", nullable = false, length = 100)
    public String getAddress2() {
        return this.address2;
    }

    public void setAddress2(String address2) {
        this.address2 = address2;
    }

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "created_at", nullable = false, length = 0)
    public Date getCreatedAt() {
        return this.createdAt;
    }

    public void setCreatedAt(Date createdAt) {
        this.createdAt = createdAt;
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "employee")
    public Set getSalaries() {
        return this.salaries;
    }

    public void setSalaries(Set salaries) {
        this.salaries = salaries;
    }

Salary.java

@Entity
@Table(name = "salary", catalog = "employee")
public class Salary implements java.io.Serializable {

    private Integer id;
    private Employee employee;
    private int basicPay;
    private int takeHome;

    public Salary() {
    }

    public Salary(Employee employee, int basicPay, int takeHome) {
        this.employee = employee;
        this.basicPay = basicPay;
        this.takeHome = takeHome;
    }

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "id", unique = true, nullable = false)
    public Integer getId() {
        return this.id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "employee_id", nullable = false)
    public Employee getEmployee() {
        return this.employee;
    }

    public void setEmployee(Employee employee) {
        this.employee = employee;
    }

    @Column(name = "basic_pay", nullable = false)
    public int getBasicPay() {
        return this.basicPay;
    }

    public void setBasicPay(int basicPay) {
        this.basicPay = basicPay;
    }

    @Column(name = "take_home", nullable = false)
    public int getTakeHome() {
        return this.takeHome;
    }

    public void setTakeHome(int takeHome) {
        this.takeHome = takeHome;
    }

when i open a page i got the following error

org.springframework.beans.factory.BeanCreationException: Error creating bean 
with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/spring-servlet.xml]: 
Invocation of init method failed; nested exception is org.hibernate.MappingException: 
Could not determine type for: java.util.Set, at table: EMPLOYEE, for columns: 
[org.hibernate.mapping.Column(salaries)]

Anything wrong on my modal class

Help is highly appreciated,
Thanks,
VKS

  • 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-26T07:43:45+00:00Added an answer on May 26, 2026 at 7:43 am

    I am not an expert, But dnt we need to tell hibernate that what should be the type of SET. because in this case, it seems to me that we are telling hibernate SET represents one to many relationship, but with which table ??

    In *.hbm.xml mapping files, I guess “table” attribute was used for this purpose.

    e.g.

    <set cascade="persist, merge, save-update, evict, replicate, lock, refresh" name="Salaries" inverse="true" lazy="true" table="salary">
                <key>
                   //code goes here
                </key>
                <one-to-many class="Salary" />
            </set>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement a simple request to Wikipedia's API using AJAX (XMLHttpRequest).
I am now trying to implement a simple HTML webpage scraper using Java.Now I
I've been trying to implement a simple component-based game object architecture using Objective-C, much
I'm new to Flex SDK and trying to implement a simple project using Doug
My first try of MVC. Am trying to implement a simple example. Inspiration from
im trying to implement simple secured client server communiction using WCF. when im launching
I'm trying to implement a simple drag/drop of images between panels using jQuery. While
I'm trying to implement simple sliding window alogirithm on two-dimensional array in C# 3.0,
I am trying to implement simple chat application using flex. In it all my
I'm trying to implement Simple chat using Servlet 3.0 and Comet pattern based on

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.