Java Code Examples for org.springframework.samples.petclinic.model.Pet#setId()

The following examples show how to use org.springframework.samples.petclinic.model.Pet#setId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JdbcPetRepositoryImpl.java    From DevOps-for-Web-Development with MIT License 5 votes vote down vote up
@Override
public void save(Pet pet) throws DataAccessException {
    if (pet.isNew()) {
        Number newKey = this.insertPet.executeAndReturnKey(
            createPetParameterSource(pet));
        pet.setId(newKey.intValue());
    } else {
        this.namedParameterJdbcTemplate.update(
            "UPDATE pets SET name=:name, birth_date=:birth_date, type_id=:type_id, " +
                "owner_id=:owner_id WHERE id=:id",
            createPetParameterSource(pet));
    }
}
 
Example 2
Source File: JdbcPetRepositoryImpl.java    From DevOps-for-Web-Development with MIT License 5 votes vote down vote up
@Override
public void save(Pet pet) throws DataAccessException {
    if (pet.isNew()) {
        Number newKey = this.insertPet.executeAndReturnKey(
            createPetParameterSource(pet));
        pet.setId(newKey.intValue());
    } else {
        this.namedParameterJdbcTemplate.update(
            "UPDATE pets SET name=:name, birth_date=:birth_date, type_id=:type_id, " +
                "owner_id=:owner_id WHERE id=:id",
            createPetParameterSource(pet));
    }
}
 
Example 3
Source File: JdbcPetRepositoryImpl.java    From docker-workflow-plugin with MIT License 5 votes vote down vote up
@Override
public void save(Pet pet) throws DataAccessException {
    if (pet.isNew()) {
        Number newKey = this.insertPet.executeAndReturnKey(
                createPetParameterSource(pet));
        pet.setId(newKey.intValue());
    } else {
        this.namedParameterJdbcTemplate.update(
                "UPDATE pets SET name=:name, birth_date=:birth_date, type_id=:type_id, " +
                        "owner_id=:owner_id WHERE id=:id",
                createPetParameterSource(pet));
    }
}
 
Example 4
Source File: JdbcPetRepositoryImpl.java    From audit4j-demo with Apache License 2.0 5 votes vote down vote up
@Override
public void save(Pet pet) throws DataAccessException {
    if (pet.isNew()) {
        Number newKey = this.insertPet.executeAndReturnKey(
                createPetParameterSource(pet));
        pet.setId(newKey.intValue());
    } else {
        this.namedParameterJdbcTemplate.update(
                "UPDATE pets SET name=:name, birth_date=:birth_date, type_id=:type_id, " +
                        "owner_id=:owner_id WHERE id=:id",
                createPetParameterSource(pet));
    }
}