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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:56:02+00:00 2026-05-26T18:56:02+00:00

i am using hibernate to create entities and database tables and i am confused

  • 0

i am using hibernate to create entities and database tables
and i am confused about the naming conventions:

let’s give an example:

we have a department entity as follows:

public class Department {

@Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    @Column(name = "department_id", unique = true, nullable = false)
    @Basic(fetch = FetchType.EAGER)
    private long id;

    @NotBlank(message = "{name.required}")
    @Size(max = 25, message = "{long.value}")
    @Column(name = "department_name", length = 25, nullable = false)
    private String name;

    @Column(name = "department_admin_id", nullable = true)
    private Integer adminId;

    @ManyToOne(cascade = CascadeType.ALL)
    @JoinColumn(name = "ik_parent_department_id")
    // set the generated column name
    private Department parentDepartment;

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    @JoinColumn(name = "department_id")
    private Set<Employee> employees = new HashSet<Employee>(0);


}

what is the best when naming for example the department admin field, do you name the column as department_admin_id or admin_id and what about the case (lower/capital) ?

and when naming the property, what do you name it, departmentAdminId or adminId ?

please advise, what is the best practice in such case, thanks.

  • 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-26T18:56:02+00:00Added an answer on May 26, 2026 at 6:56 pm

    If your table is called department then there’s not much benefit in all it’s columns beginning with department_. Just call them id, name, admin_id, etc.

    After all, the members of you’re class aren’t prefixed in this way are they? The columns already have an implicit relation to department by being in the department table. Further explanation is over verbose and not needed.

    Edit:
    In java classes I would use camel case. For the column name I would seperate with underscores. Most DBs are case insensitive with table and column names.

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

Sidebar

Related Questions

I am using NHibernate's SchemaExport to create my database schema. I have 1 legacy
I've mapped two entities using JPA (specifically Hibernate). Those entities have a one-to-many relationship
I am trying to make a simple example of Hibernate. I have two entities:
I am developing a tool that handles some database entities using JPA2, with hibernate
I'm using Hibernate and I have a process/best practices issue. For an example, lets
I have 2 tables in my database: CREATE TABLE [items]( [item_id] [int] IDENTITY(1,1) NOT
I needed to create an application using Struts2 as MVC,Hibernate for data access and
I'm trying to create a web application using maven, tomcat and hibernate. Now I'm
I am using Hibernate in a Java application to access my Database and it
JPA + Hibernate I'm using this code to create a new AvatarAttributeOwnership ( AAO

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.