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

  • Home
  • SEARCH
  • 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 6762281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:18:05+00:00 2026-05-26T14:18:05+00:00

I am trying to generate some tables using hibernate. I have following classes :

  • 0

I am trying to generate some tables using hibernate. I have following classes :

class Candidate {
    long candidateID;
    String candidate_name;
    List<Project> projects;
}

class Project {
    long projectID;
    Set<String> technologies;
}

and I want to generate tables like below :

+------------------------------+
      candidates
------------------------------|
candidate_id | candidate_name  
+------------------------------+

+------------------------------+
      projects 
------------------------------|
candidate_id | project_id  
+------------------------------+

+----------------------------------------+
      project_technologies 
-----------------------------------------|
candidate_id | project_id | technology_id  
+----------------------------------------+

+------------------------------+
      technologies 
-------------------------------|
technology_id | technology_name  
+------------------------------+

and currently mapping file for Project class is as follows :

<hibernate-mapping package="com.shekhar.tmpProject.model">
    <class name="Project" table="PROJECTS">
        <id name="projectID" column="PROJECT_ID" type="integer"
            unsaved-value="0">
            <generator class="native" />
        </id>
        <set name="technologies" table="PROJECT_TECHNOLOGIES">
            <key column="PROJECT_ID" />
            <element column="TECHNOLOGY_NAME" type="string" />
        </set>
        </class>
</hibernate_mapping>

but currently hibernate is not generating the tables the way I want. What I am getting now is something like as follows :

mysql> desc project_technologies;
+------------+--------------+------+-----+---------+-------+
| Field      | Type         | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+-------+
| PROJECT_ID | int(11)      | NO   | PRI | NULL    |       |
| TECHNOLOGY | varchar(255) | NO   | PRI | NULL    |       |
+------------+--------------+------+-----+---------+-------+
2 rows in set (0.03 sec)

mysql> desc projects;
+--------------+------------+------+-----+---------+----------------+
| Field        | Type       | Null | Key | Default | Extra          |
+--------------+------------+------+-----+---------+----------------+
| PROJECT_ID   | int(11)    | NO   | PRI | NULL    | auto_increment |
| CANDIDATE_ID | bigint(20) | YES  | MUL | NULL    |                |
+--------------+------------+------+-----+---------+----------------+
5 rows in set (0.01 sec)

mysql> desc candidates;
+----------------+--------------+------+-----+---------+----------------+
| Field          | Type         | Null | Key | Default | Extra          |
+----------------+--------------+------+-----+---------+----------------+
| CANDIDATE_ID   | bigint(20)   | NO   | PRI | NULL    | auto_increment |
| CANDIDATE_NAME | varchar(255) | NO   |     | NULL    |                |
+----------------+--------------+------+-----+---------+----------------+
2 rows in set (0.01 sec)

Can anyone please help me in this?

  • 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-26T14:18:06+00:00Added an answer on May 26, 2026 at 2:18 pm

    You will have to design a Technology entity if you want to have control over its layout.

    class Technology {
       long technologyId;
       String technologyName;
    }
    

    In your Project mapping you will have to use a <many-to-many> mapping instead of <element>

    EDIT

    You will always have to create concrete classes for unique Entities if you are using hibernate. For further inheritance mapping see following documentation, which is the other way around. (Multiple entities – one or more tables)

    http://docs.jboss.org/hibernate/core/3.3/reference/en/html/inheritance.html

    Another chance is to use the abstract attribute in your <class> in combination with <union-subclass> which is explained in detail here:

    http://docs.jboss.org/hibernate/core/3.3/reference/en/html/mapping.html#mapping-declaration-unionsubclass

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

Sidebar

Related Questions

I am trying to generate some code at runtime using the DynamicMethod class in
I am trying to generate some code using CodeDom. I wanted to know if
I'm trying to generate a JSON response that includes some HTML. Thus, I have
I'm trying to generate code coverage reports with EMMA using tests of which some
I'm using Hibernate tools 3.40 in Eclipse (Helios). I'm trying to generate POJOs from
I'm trying to generate some code at runtime where I put in some boiler-plate
I'm trying to generate some url 'slugs' for my website. It's based upon a
currently i'm trying to use imagick to generate some images without saving them on
I'm trying to write some LINQ To SQL code that would generate SQL like
I'm getting an 'System.OutOfMemoryException' when trying to generate some HTML reports. How can I

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.