Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

403
Visualizações
Groovy Grails Hibernate : batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1

I'm new in Hibernate and Groovy, i dont know why i got error id in this code. My Grails version is 2.1.1

Grails-app/Domain using Hibernate

class Deposit implements Validateable{

BigInteger **id**
BigDecimal amount
BigDecimal currentBalance

static mapping = {
    datasource 'test'
    table 'DEPOSIT'
    id column: "ID"
    amount column: "amount"
    currentBalance column: "currentBalance"

    version false
}

DepositContoller

def depositTrx(){
    def savedata = new Deposit()    
    savedata.id=3;
    savedata.amount=122223;
    savedata.currentBalance=1511122;
    savedata.save()
    redirect(uri: "/Deposit")
}

if I use id in grails-app/Domain, i got this error: batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1

when I change grails-app/Domain: id become to ide or whatever, the code successfully save data to database, but page show me this error null id in Deposit entry (don't flush the Session after an exception occurs)

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

If you would like to be able to manually assign the id you can set the generator to assigned:

static mapping = {
    id generator: 'assigned', column: "ID"
    ...
}

http://docs.grails.org/3.1.1/ref/Database%20Mapping/id.html

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda