序列不存在,hibernate和JPA 2.1

Dre*_*208 10 jpa spring-data-jpa spring-boot

我收到一个错误说

`Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet] with root cause
java.sql.SQLSyntaxErrorException: ORA-02289: sequence does not exist`
Run Code Online (Sandbox Code Playgroud)

当我尝试创建用户时会发生此错误.

  @RequestMapping(method = POST)
    public UserDto createUser(@RequestBody userDto user) {
        Preconditions.checkNotNull(user);

        return Preconditions.checkNotNull(service.create(user));
    }
Run Code Online (Sandbox Code Playgroud)

然而,我能够delete而且get也不createupdate.令人沮丧的是,我在尝试时没有出现任何错误update,它只是不是这样.

我没有真正领先于哪里看.我尝试了许多不同的方法来解决这个问题,但没有用.

我发现了一篇帖子:

@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="SEQUENCE1")
@SequenceGenerator(name="SEQUENCE1", sequenceName="SEQUENCE1", allocationSize=1)
private int user_id;
Run Code Online (Sandbox Code Playgroud)

在此链接:SOF链接

它抱怨我用netbeans生成的这个实体,我目前正在使用Intellij.任何意见,将不胜感激.

Nik*_*nko 3

创建新实体的代码Campaign似乎不正确。

public CampaignDto create(CampaignDto campaignDto) {
    Campaign campaign = mapper.mapReverse(campaignDto);

    System.out.println(campaign.toString());

    // Following 2 lines must be added to obtain and use managed Shop entity
    Shop existingShop = shopRepository.findOne(campaignDto.getShopId());
    campaign.setShop(existingShop);

    campaign = campaignRepository.save(campaign);
    CampaignDto createdCampaign = mapper.map(campaign);

    return createdCampaign;
}
Run Code Online (Sandbox Code Playgroud)