I try to use CrudRepository on my work. And When the sql request appear on my log, It's just abnormal.
The real table is 'AllDatabase.AllUserInfo' but the generated sql request look like 'all_user_info alluresinf0_', which is unusable.
I have been all over the internet and nobody seems to face my problem (as far as I know). So please somebody tell me if I'm missing some configuration in my project.
I work on Intellij Idea with 'Spring Initializer' with 'Web' , 'JPA' , 'MySQL' selected. These are my code.
here is my Repository
package com.chuchurest.proj.Repository;
import com.chuchurest.proj.Entity.AllUserInfo;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* Created by slimshady23 on 6/25/2017 AD.
*/
@Transactional
@Repository
public interface UserRepository extends CrudRepository<AllUserInfo,String> {
}
here is The 'AllUserInfo' Entity
package com.chuchurest.proj.Entity;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Id;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import java.io.Serializable;
/**
* Created by slimshady23 on 6/23/2017 AD.
*/
@Entity
@Table(name = "AllUserInfo")
public class AllUserInfo {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private String Id;
@Column(name="username")
private String Username;
@Column(name="password")
private String Password;
@Column(name="email")
private String Email;
@Column(name="phone")
private String Phone;
@Column(name="rating")
private Integer Rating;
@Column(name="skill")
private Integer Skill;
@Column(name="description")
private String Description;
public String getId() {
return Id;
}
public void setId(String id) {
Id = id;
}
public String getUsername() {
return Username;
}
public void setUsername(String username) {
Username = username;
}
public String getPassword() {
return Password;
}
public void setPassword(String password) {
Password = password;
}
public String getEmail() {
return Email;
}
public void setEmail(String email) {
Email = email;
}
public String getPhone() {
return Phone;
}
public void setPhone(String phone) {
Phone = phone;
}
public Integer getRating() {
return Rating;
}
public void setRating(Integer rating) {
Rating = rating;
}
public Integer getSkill() {
return Skill;
}
public void setSkill(Integer skill) {
Skill = skill;
}
public String getDescription() {
return Description;
}
public void setDescription(String description) {
Description = description;
}
}
And this is how I invoke the save() method
package com.chuchurest.proj.Service;
import com.chuchurest.proj.DAO.UserInfoDAO;
import com.chuchurest.proj.Entity.AllUserInfo;
import com.chuchurest.proj.Repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Created by slimshady23 on 6/24/2017 AD.
*/
@Service
public class AppService {
@Autowired
private UserRepository userRepository;
public void PerformRegister(AllUserInfo userinfo)
{
userRepository.save(userinfo);
}
}
And here is the Application.properties
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/AllDatabase
spring.datasource.username=root
spring.datasource.password= ******
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQLDialect
spring.jpa.properties.hibernate.id.new_generator_mappings = false
spring.jpa.properties.hibernate.format_sql = true
spring.jpa.show-sql= true
logging.level.org.hibernate.SQL=DEBUG
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE