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

The Archive Base Latest Questions

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

I’m having trouble getting my code to work, I’ve tried about everything and nothing

  • 0

I’m having trouble getting my code to work, I’ve tried about everything and nothing seems to work;

My Code :
1. SpelerOpstelling.java

 package model;

import org.hibernate.annotations.Cascade;

import javax.persistence.*;

@Entity
@Table(name = "SpelerOpstelling")
public class SpelerOpstelling {

private int SpelerOpstellingID;
private char positie;
private String functie;
private Speler speler;


public SpelerOpstelling() {
}

public SpelerOpstelling(char positie, String functie, Speler speler) {
    this.positie = positie;
    this.functie = functie;
    this.speler = speler;
}


@Id
@GeneratedValue (strategy=GenerationType.IDENTITY)
@Column(name = "SpelerOpstelling_ID")
    public int getSpelerOpstellingID() {
    return SpelerOpstellingID;
}

public void setSpelerOpstellingID(int spelerOpstellingID) {
    SpelerOpstellingID = spelerOpstellingID;
}



@Column(name = "functie", nullable = false, length = 100)
   public String getFunctie() {
    return functie;
}

public void setFunctie(String functie) {
    this.functie = functie;
}



@Column(name= "positie")
      public char getPositie() {
    return positie;
}

public void setPositie(char positie) {
    this.positie = positie;
}

@ManyToOne(cascade = CascadeType.ALL )
@Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE})
@JoinColumn( name = "Speler_ID" )
private Speler sp;
public Speler getSpeler() {
    return speler;
}

public void setSpeler(Speler speler) {
    this.speler = speler;
}

}

Speler.java

    package model;

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

@Entity
@Table(name = "Speler")
public class Speler {
  private int speler_ID;
private String naam;
private String adres;
private String gemeente;
private String telefoonnummer;
private String fax;
private String email;

public Speler() {
}

public Speler(String naam, String adres, String gemeente, String fax, String telefoonnummer, String email) {
    this.naam = naam;
    this.adres = adres;
    this.gemeente = gemeente;
    this.fax = fax;
    this.telefoonnummer = telefoonnummer;
    this.email = email;
}



@Id
@GeneratedValue
@Column(name = "Speler_ID")
  public int getSpeler_ID() {
    return speler_ID;
}

public void setSpeler_ID(int speler_ID) {
    this.speler_ID = speler_ID;
}


@Column(name = "naam", nullable = false, length=250)
 public String getNaam() {
    return naam;
}

public void setNaam(String naam) {
    this.naam = naam;
}



@Column(name = "adres", nullable = false, length=50)
   public String getAdres() {
    return adres;
}

public void setAdres(String adres) {
    this.adres = adres;
}



@Column(name = "gemeente", nullable = false, length=50)
    public String getGemeente() {
    return gemeente;
}

public void setGemeente(String gemeente) {
    this.gemeente = gemeente;
}

@Column(name = "fax", nullable = false, length=10)


public String getFax() {
    return fax;
}

public void setFax(String fax) {
    this.fax = fax;
}

@Column(name = "telefoonnummer", nullable = false, length=10)

public String getTelefoonnummer() {
    return telefoonnummer;
}

public void setTelefoonnummer(String telefoonnummer) {
    this.telefoonnummer = telefoonnummer;
}

@Column(name = "email", nullable = false, length=10)

public String getEmail() {
    return email;
}

public void setEmail(String email) {
    this.email = email;
}

}

Error I get when I run my main class, I make a new Speler, then I try to insert a SpelerOpstelling and get the error that it can’t find the column speler.. I’m really confused about this since I just want the ID of the Speler into my database.

Initial SessionFactory creation failed.org.hibernate.MappingException: Could not determine type for: model.Speler, at table: SpelerOpstelling, for columns: [org.hibernate.mapping.Column(speler)]
Exception in thread "main" java.lang.ExceptionInInitializerError
    at persistence.HibernateUtil.<clinit>(HibernateUtil.java:17)
    at model.Start.main(Start.java:38)
    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 com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: org.hibernate.MappingException: Could not determine type for: model.Speler, at table: SpelerOpstelling, for columns: [org.hibernate.mapping.Column(speler)]
    at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:306)
    at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:290)
    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:235)
    at org.hibernate.cfg.Configuration.validate(Configuration.java:1362)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1865)
    at persistence.HibernateUtil.<clinit>(HibernateUtil.java:12)
    ... 6 more
  • 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-26T10:27:08+00:00Added an answer on May 26, 2026 at 10:27 am

    You can’t apply annotations to methods or fields randomly. Normally, you should apply your annotations the same way as @Id.

    In your case in class SpelerOpstelling you applied @Id to getter method but

    @ManyToOne(cascade = CascadeType.ALL )
    @Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE})
    @JoinColumn( name = "Speler_ID" )
    private Speler sp;
    

    is applied to field. So Hibernate just ignores this annotation.

    Just move these annotation one line lower to apply to getter as well:

    private Speler sp;
    
    @ManyToOne(cascade = CascadeType.ALL )
    @Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE})
    @JoinColumn( name = "Speler_ID" )
    public Speler getSpeler() {
        return speler;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have just tried to save a simple *.rtf file with some websites and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have thousands of HTML files to process using Groovy/Java and I need to
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.