无法提取ResultSet; SQL [n / a]当我尝试使用Repository保存实体时

时间:2016-08-09 08:43:59

标签: spring hibernate spring-boot repository spring-data-jpa

我尝试使用SpringRepository,但我有一些错误。

我的实体

@Entity
@Table(name = "MB_SUBSCRIBER")
@Getter
@Setter
public class Subscriber {
    public Subscriber() {}
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "MB_SUBSCRIBER_SEQ")
    @SequenceGenerator(name = "MB_SUBSCRIBER_SEQ", sequenceName = "MB_SUBSCRIBER_SEQ", allocationSize = 1)
    private Long id;
    @Column(name = "dateCreated")
    private Date dateCreated;
    @Column(name = "msisdn")
    private String msisdn;
    @Column(name = "ban")
    private String ban;
    @Column(name = "amount")
    private Double amount;
}

存储库类

public interface SubscriberReposetory extends JpaRepository<Subscriber, Long> {
}

当我尝试Subscriber savedSubscriber = subscriberReposetory.save(subscriber);

我收到错误

Method threw 'org.springframework.dao.InvalidDataAccessResourceUsageException' exception.

could not extract ResultSet; SQL [n/a]

org.hibernate.exception.SQLGrammarException: could not extract ResultSet

我使用带有序列的Oracle DB

修改

#Basic Spring Boot Config for Oracle
oracle.url=jdbc:oracle:thin:@//mydb:1521/mydb
oracle.username=pass
oracle.password=login
spring.datasource.driver-class-name=oracle.jdbc.OracleDriver

#hibernate config
spring.jpa.database-platform=org.hibernate.dialect.Oracle10gDialect

我认为这个错误是因为我的表没有创建,但是不知道如何写出配置

1 个答案:

答案 0 :(得分:0)

我在忘记用 @Repository 注释标记我的存储库类时遇到了这个问题。

应该是:

startDt