I have started to work on a new Spring Boot using Hibernate application started by another person and I have the following problem: during the application startup I obtain the following error:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'placeSearcherController': Unsatisfied dependency expressed through field 'mainSearchServices';
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'mainSearchServicesImpl': Unsatisfied dependency expressed through field 'accomodationDAO';
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'accomodationDAOImpl': Unsatisfied dependency expressed through field 'sessionFactory';
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [com/betrivius/config/DatabaseConfig.class]: Invocation of init method failed;
nested exception is org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: wrong column type encountered in column [id] in table [accomodation]; found [bigint (Types#BIGINT)], but expecting [integer (Types#INTEGER)]
So, the last exacption into this exceptions chain is:
nested exception is org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: wrong column type encountered in column [id] in table [accomodation]; found [bigint (Types#BIGINT)], but expecting [integer (Types#INTEGER)]
I think that it only means that on the database table I have a BigInt value for the id column of the accomodation table but on the Accomodation class that maps this table I have:
@Entity
@Table(name = "accomodation")
public class Accomodation implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Integer id;
..........................................................
..........................................................
..........................................................
}
Is it the problem? So what is the correct Java type for MySql BigInt data type? Reading online I fount that somoene use Long and someone else use BigInteger. What is the best choice?
Another important doubt is related about how to correctly read the previous excepeptions chain:
It first show an error into the placeSearcherController bean (it is thrown an UnsatisfiedDependencyException).
From what I have understand it means that the error into the placeSearcherController bean depends by the same exception that is thrown into the mainSearchServicesImpl bean (used by placeSearcherController) and so on untile came to the first place where this exception was thrown that is the AccomodationDAOImpl instance (where the query is performed).
Is this interpretation correct?