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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:27:07+00:00 2026-06-12T01:27:07+00:00

When hinernate tries to map this class to MySQL database /* *To change this

  • 0

When hinernate tries to map this class to MySQL database

/*
*To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package projekat.entities;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.persistence.*;
import org.apache.tapestry5.beaneditor.NonVisual;

/**
 *
 * @author nikola
 */
@Entity
public class Student implements Serializable {

  @Id
  @NonVisual
  @GeneratedValue(strategy = GenerationType.AUTO)
  @Basic(optional = false)
  private Long kljuc;
  @Basic(optional = false)
  private String ime;
  @Basic(optional = false)
  private String prezime;
  @Basic(optional = false)
  private Integer index;
  @ManyToMany
  private List<Grupa> grupaList = new ArrayList<Grupa>();

  public NewClass() {
  }

  public Long getKljuc() {
    return kljuc;
  }

  public void setKljuc(Long kljuc) {
    this.kljuc = kljuc;
  }

  public String getIme() {
    return ime;
  }

  public void setIme(String ime) {
    this.ime = ime;
  }

  public String getPrezime() {
    return prezime;
  }

  public void setPrezime(String prezime) {
    this.prezime = prezime;
  }

  public Integer getIndex() {
    return index;
  }

  public void setIndex(Integer index) {
    this.index = index;
  }

  public List<Grupa> getGrupaList() {
    return grupaList;
  }

  public void setGrupaList(List<Grupa> grupaList) {
    this.grupaList = grupaList;
  }

  @Override
  public int hashCode() {
    int hash = 5;
    hash = 83 * hash + Objects.hashCode(this.kljuc);
    hash = 83 * hash + Objects.hashCode(this.ime);
    hash = 83 * hash + Objects.hashCode(this.prezime);
    hash = 83 * hash + Objects.hashCode(this.index);
    return hash;
  }

  @Override
  public boolean equals(Object obj) {
    if (obj == null) {
      return false;
    }
    if (getClass() != obj.getClass()) {
      return false;
    }
    final Student other = (Student) obj;
    if (!Objects.equals(this.kljuc, other.kljuc)) {
      return false;
    }
    if (!Objects.equals(this.ime, other.ime)) {
      return false;
    }
    if (!Objects.equals(this.prezime, other.prezime)) {
      return false;
    }
    if (!Objects.equals(this.index, other.index)) {
      return false;
    }
    return true;
  }

  @Override
  public String toString() {
    return "Student{" + "ime=" + ime + ", prezime=" + prezime + ", index=" + index + '}';
  }
}

Following output is shown in tomcat log

Unsuccessful: create table Student (kljuc bigint not null auto_increment, ime varchar(255) not null, index integer not null, prezime varchar(255) not null, primary key (kljuc))
20:03:30,540 ERROR SchemaExport:387 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'integer not null, prezime varchar(255) not null, primary key (kljuc))' at line 1
  • 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-06-12T01:27:08+00:00Added an answer on June 12, 2026 at 1:27 am

    Turns out error was in the class field index which is a keyword in MySQL.
    I have been stuck on this for at least 2 days. Doing reinstall of MySQL server, IDE, searching hibernate documentation, etc…

      @Basic(optional = false)
      private Integer index;
    //to
      @Basic(optional = false)
      private Integer indeks;
    

    And I am simply putting this on just to help me and others who have same problem.

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

Sidebar

Related Questions

I am using Hibernate to map with MySQL I have an entity class in
I tried to map this three classes: @Entity class Photo { ... @ManyToOne private
I have bi-directional relationship like this... Person.java public class Person{ @JsonIgnore @OneToMany(targetEntity=PersonOrganization.class, cascade=CascadeType.ALL, fetch=FetchType.EAGER,
I am using hibernate to map my classes to oracle database. But when I
I want to map a class to a table and a subclass to another
I have the following classes which I would like to map using NHibernate class
How can i map a date from a java object to a database with
I am using MySQL database with Hibernate and there are certain Enum fields that
Hibernate connections to MySQL my db are not closing. After clicking 10 times in
Using hibernate, how can I persist a class with a List<String> field? Consider the

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.