Java Spring Hibernate未将实体映射到PostGres中的现有表
您好,我在hibernate中遇到了一个问题,它没有将名为“召唤者”的实体映射到Postgre中名为“召唤者”的现有表 Postgre版本:9.2 Sts版本:4.4.2.1发布 召唤者Java Spring Hibernate未将实体映射到PostGres中的现有表,java,spring,hibernate,Java,Spring,Hibernate,您好,我在hibernate中遇到了一个问题,它没有将名为“召唤者”的实体映射到Postgre中名为“召唤者”的现有表 Postgre版本:9.2 Sts版本:4.4.2.1发布 召唤者 package hello; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; @Entity @Tab
package hello;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "summoners")
public class summoners {
@Id
@Column(name = "SummonerName")
private String SummonerName;
@Column(name = "SummonerEncryptedID")
private String SummonerEncryptedID;
}
callererepository.java
package hello;
import java.util.List;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
// This will be AUTO IMPLEMENTED by Spring into a Bean called userRepository
// CRUD refers Create, Read, Update, Delete
public interface SummonerRepository extends CrudRepository<summoners, Integer> {
}
包你好;
导入java.util.List;
导入org.springframework.data.jpa.repository.Query;
导入org.springframework.data.repository.crudepository;
//这将由Spring自动实现到名为userRepository的Bean中
//CRUD指的是创建、读取、更新和删除
公共接口CallerRepository扩展了Crudepository{
}
GreetingController.java
package hello;
import java.util.concurrent.atomic.AtomicLong;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class GreetingController {
private static final String template = "Hello, %s!";
private final AtomicLong counter = new AtomicLong();
@Autowired
private SummonerRepository summonerRepository;
@RequestMapping("/greeting")
public Greeting greeting(@RequestParam(value="name", defaultValue="World") String name) {
return new Greeting(counter.incrementAndGet(),
String.format(template, name));
}
@RequestMapping("/summoners")
public Iterable<summoners> summoners() {
return summonerRepository.findAll();
}
}
包你好;
导入java.util.concurrent.AtomicLong;
导入org.springframework.beans.factory.annotation.Autowired;
导入org.springframework.web.bind.annotation.RequestMapping;
导入org.springframework.web.bind.annotation.RequestParam;
导入org.springframework.web.bind.annotation.RestController;
@RestController
公共类迎宾控制器{
私有静态最终字符串模板=“您好,%s!”;
私有最终AtomicLong计数器=新的AtomicLong();
@自动连线
私人传票保存传票保存;
@请求映射(“/greeting”)
公共问候语(@RequestParam(value=“name”,defaultValue=“World”)字符串名){
返回新的问候语(counter.incrementAndGet(),
格式(模板、名称));
}
@请求映射(“/callers”)
公开传唤人(){
return callierrepository.findAll();
}
}
固定的
问题是postgre 9.2.0在以大写字符开头的列上出现问题…很高兴听到它的修复 除此之外,我还能看到
public interface SummonerRepository extends CrudRepository<summoners, Integer>
公共接口召唤存储库扩展了crudepository
应该是
public interface SummonerRepository extends CrudRepository<summoners, String>
公共接口召唤存储库扩展了crudepository