Modified from https://github.com/amitjindal/generator-jhipster-postgresstring-converter
As this is a JHipster module, we expect you have JHipster and its related tools already installed:
To install this module:
npm install -g generator-jhipster-string-converter
To update this module:
npm update -g generator-jhipster-string-converter
import org.hibernate.annotations.GenericGenerator;
// ...
@Id
@GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy = "uuid2")
private String id;
// ...
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
// ...
@SuppressWarnings("unused")
@Repository
public interface AppRepository extends JpaRepository<App, String> {
}
/**
* Get the "id" app.
*
* @param id the id of the entity
* @return the entity
*/
Optional<App> findOne(String id);
/**
* Delete the "id" app.
*
* @param id the id of the entity
*/
void delete(String id);
/**
* Get one app by id.
*
* @param id the id of the entity
* @return the entity
*/
@Override
@Transactional(readOnly = true)
public Optional<App> findOne(String id) {
log.debug("Request to get App : {}", id);
return appRepository.findById(id);
}
/**
* Delete the app by id.
*
* @param id the id of the entity
*/
@Override
public void delete(String id) {
log.debug("Request to delete App : {}", id);
appRepository.deleteById(id);
}
/**
* GET /apps/:id : get the "id" app.
*
* @param id the id of the app to retrieve
* @return the ResponseEntity with status 200 (OK) and with body the app, or with status 404 (Not Found)
*/
@GetMapping("/apps/{id}")
@Timed
public ResponseEntity<App> getApp(@PathVariable String id) {
log.debug("REST request to get App : {}", id);
Optional<App> app = appService.findOne(id);
return ResponseUtil.wrapOrNotFound(app);
}
/**
* DELETE /apps/:id : delete the "id" app.
*
* @param id the id of the app to delete
* @return the ResponseEntity with status 200 (OK)
*/
@DeleteMapping("/apps/{id}")
@Timed
public ResponseEntity<Void> deleteApp(@PathVariable String id) {
log.debug("REST request to delete App : {}", id);
appService.delete(id);
return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert(ENTITY_NAME, id.toString())).build();
}