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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:28:00+00:00 2026-05-18T05:28:00+00:00

I am facing problem with hibernate annotations.For the code shown below I have a

  • 0

I am facing problem with hibernate annotations.For the code shown below I have a hotel class ,customer class and i use customerhotelbooking to keep track of which customer has booked which hotel and vice-versa.
but when i place annotations on getters of hotel and customer it gives an exception and surprisingly it works when i place it on attributes.
can somebody tell why is it so??

`Caused by: org.hibernate.MappingException: Could not determine type for: com.xebia.hotelBooking.domain.Customer, at table: CustomerHotelBooking, for columns: [org.hibernate.mapping.Column(customer)]
 at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:290)
 at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:274)
 at org.hibernate.mapping.Property.isValid(Property.java:217)
 at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:464)
 at org.hibernate.mapping.RootClass.validate(RootClass.java:236)
 at org.hibernate.cfg.Configuration.validate(Configuration.java:1193)
 at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1378)
 at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:954)
 at org.jboss.seam.persistence.HibernateSessionFactory.createSessionFactory(HibernateSessionFactory.java:165)
 at org.jboss.seam.persistence.HibernateSessionFactory.startup(HibernateSessionFactory.java:79)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
 at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
 at org.jboss.seam.Component.callComponentMethod(Component.java:2249)
 at org.jboss.seam.Component.callCreateMethod(Component.java:2172)
 at org.jboss.seam.Component.newInstance(Component.java:2132)`

I have Hotel bean as shown `

@Id
 @GeneratedValue
 private int id;

 private String description;

 private String city;

 private String name;

 private String rating ;

 private int isBooked; 
 `

Cusomer bean as `

        @Id
 @GeneratedValue
 private int id;

 private String userName;

 private String password;

`

and CustomerHotelBooking class as

       @Id
 @GeneratedValue
 private int id;

 private Hotel hotel;

 private Customer customer;


        @ManyToOne
 @Cascade(value = { CascadeType.ALL })
 public Customer getCustomer() {
  return customer;
 }

 /**
  * @param customer the customer to set
  */
 public void setCustomer(Customer customer) {
  this.customer = customer;
 }

 /**
  * @return the user
  */



 /**
  * @return the hotel
  */
        @ManyToOne
 @Cascade(value = { CascadeType.ALL })
 public Hotel getHotel() {
  return hotel;
 }

 /**
  * @param hotel
  *            the hotel to set
  */
 public void setHotel(Hotel hotel) {
  this.hotel = hotel;
 }
  • 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-18T05:28:01+00:00Added an answer on May 18, 2026 at 5:28 am

    The docs say:

    2.2.2.2. Access type

    By default the access type of a class hierarchy is defined by the position of the @Id or @EmbeddedId annotations. If these annotations are on a field, then only fields are considered for persistence and the state is accessed via the field. If there annotations are on a getter, then only the getters are considered for persistence and the state is accessed via the getter/setter. That works well in practice and is the recommended approach.

    So it is expected and documented behaviour – so place your annotations consistently – either fields or getters.

    (If you read the documentation below what I quoted, it says there is a way to mix access types, using the @Access annotation, but I would not recommend that – be consistent. I, personally, prefer putting the annotations on the fields)

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

Sidebar

Related Questions

That was helpful kgiannakakis. I'm facing a problem as below: a = ['zbc','2.3'] for
I'm facing what I think is a simple problem with Hibernate, but can't solve
I am facing a problem in Hibernate property formula field - I'm unable to
I'm facing a problem with Hibernate. My current project is a little game. In
I am facing a problem with parent child type relations. Hibernate docs say to
This is a problem I have been trying to track down for a couple
i am using hibernate as ORM tool, i am facing one problem, i need
Currently We are facing a lot of problem in migrating our Application from Hibernate
Hi i have done with status update in tumbler but i am facing problem
I have to enter some data to database, see my code. I am facing

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.