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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:06:00+00:00 2026-05-23T02:06:00+00:00

I recently started my first Java project that uses Hibernate (and JPA Annotations) for

  • 0

I recently started my first Java project that uses Hibernate (and JPA Annotations) for persistence.

I’ve got the following classes:

User class

*some imports*
@Entity
public class Owner {
        private int id;
        private String name;
        @OneToOne(fetch=FetchType.LAZY)
        @JoinColumn(name="id")
        private Pet pet;

        @Id
        @GeneratedValue
        public int getId() {
            return id;
        }
        public void setId(int id) {
            this.id = id;
        }
        public String getName() {
            return name;
        }
        public void setName(String name) {
            this.name = name;
        }

        public void setPet(Pet pet) {
            this.pet = pet;
        }
        public Pet getPet() {
            return pet;
        }
    }

Pet Class

*some imports*
@Entity 
public class Pet {
        private String name;
        @Id
        @GeneratedValue
        private int id;

        public void setId(int id) {
            this.id = id;
        }
        public int getId() {
            return id;
        }
        public String getName() {
            return name;
        }
        public void setName(String name) {
            this.name = name;
        }
    }

Whenever I try to save an object, Hibernate gives me the following error output.

Exception in thread "main" org.hibernate.MappingException: Could not determine type for: Pet, at table: Owner, for columns: [org.hibernate.mapping.Column(pet)]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:306)
at org.hibernate.mapping.Column.getSqlTypeCode(Column.java:164)

What am I missing? I can’t figure out how to do this PF-FK mapping.

Do I need to tell Hibernate which table Pet maps into or is it smart enough to do that? Could someone please suggest how I can change my declaration of the Pet ivar so that Hibernate and I can be happy? 🙂

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-23T02:06:01+00:00Added an answer on May 23, 2026 at 2:06 am

    I guess it’s caused by the fact that you mixed annotations on fields and properties. You need to place annotations in a consistent way, unless you explicitly indicate how they are placed with @Access/@AccessType.

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

Sidebar

Related Questions

I've recently started developing my first serious application which uses a SQL database, and
I recently started a new webforms project and decided to separate the business classes
I recently started my first project for iOS 5. I started with an empty
I recently started attending two classes in school that focus on networking, one regarding
I have recently started learning java as my first ever step into object oriented
I've recently started learning and utilizing WiX, and my first true project with WiX
I recently started programming my first node.js. However, I discovered that I am unable
Hello First sorry for my english. I have started recently my first project on
I've recently started using an IoC container for the first time, but I'm not
I have recently started learning F#, and this is the first time I've ever

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.