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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:07:49+00:00 2026-05-27T02:07:49+00:00

I try to get hibernate 4 running (shipped with JBoss AS 7) and deploy

  • 0

I try to get hibernate 4 running (shipped with JBoss AS 7) and deploy my application as EAR (persistence.xml iis in the META-INF of the EAR). Hibernate seems to run. I have two classes and is does not complain as long as I do not use one class inside the other.

I have a session:

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name = "sessions")
public class Session {
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    public Long dbid;
    public String id;
    public User user; // This is problematic!

    public Session() {
    }

    public Session(User user) {
        this.id = generateID();
        this.user = user;
    }

    private String generateID() {
        return Long.toString((long) (Math.random() * 1000000000.0));
    }

    @Override
    public int hashCode() { [...] }

    @Override
    public boolean equals(Object obj) { [...] }
}

And I have a user

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name = "users")
public class User {
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    public Long dbid;
    public String name;
    public String password;

    public User() {
    }

    public User(String name, String password) {
        this.name = name;
        this.password = password;
    }

    @Override
    public int hashCode() { [...] }

    @Override
    public boolean equals(Object obj) { [...] }
}

If I start the server it complains:

Caused by: org.hibernate.MappingException: Could not determine type for: myproject.model.User, at table: sessions, for columns: [org.hibernate.mapping.Column(user)]
    at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:303)
    at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:287)
    at org.hibernate.mapping.Property.isValid(Property.java:215)
    at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:466)
    at org.hibernate.mapping.RootClass.validate(RootClass.java:267)
    at org.hibernate.cfg.Configuration.validate(Configuration.java:1285)

It does not complain if I remove public User user; from the session class.

Both classes are listed in the persistence.xml and I have tried:

  1. generated getters/setters and place the annotations at the getters
  2. generate hashCode and equals appropriately

What could I check additionally? What might be the problem?

  • 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-27T02:07:50+00:00Added an answer on May 27, 2026 at 2:07 am

    Add the @ManyToOne annotation to the User member in your session class (assuming a single user can have multiple sessions in your database … if a user only ever has one extant session, you can use @OneToOne

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

Sidebar

Related Questions

I try to get the whole content between an opening xml tag and it's
how can i access Hibernate group by results. I try to get counts of
I want to use Infinispan with hibernate second level cache. My application is running
My Hibernate annotations work when my application is running on the server, but when
I'm doing a project with Spring 3 + Hibernate. When I try to get
When I try to get hibernate session (Session session = HibernateUtil.getSession();) I get an
I get this error when I try recreate tables in my database with hibernate.
I am developing an application using hibernate. When I try to create a Login
I try get a my attribute inside Fancybox, and I get when I use
i try to get my FragmentPagerAdapter working, but the examples are a bit to

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.