Example usage for org.hibernate Query setComment

List of usage examples for org.hibernate Query setComment

Introduction

In this page you can find the example usage for org.hibernate Query setComment.

Prototype

Query<R> setComment(String comment);

Source Link

Document

Set the comment for this query.

Usage

From source file:org.zanata.rest.service.ProjectsService.java

License:Open Source License

@Override
@GET/*ww w.  j av  a2s. c o  m*/
@Produces({ MediaTypes.APPLICATION_ZANATA_PROJECTS_XML, MediaTypes.APPLICATION_ZANATA_PROJECTS_JSON,
        MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Wrapped(element = "projects", namespace = Namespaces.ZANATA_API)
public Response get() {
    Query query = session.createQuery("from HProject p");
    query.setComment("ProjectsService.get");
    @SuppressWarnings("unchecked")
    List<HProject> projects = query.list();

    List<Project> projectRefs = new ArrayList<Project>(projects.size());

    for (HProject hProject : projects) {
        // Ignore Obsolete projects
        if (!Objects.equal(hProject.getStatus(), OBSOLETE)) {
            String projectType;
            if (hProject.getDefaultProjectType() == null) {
                projectType = "";
            } else {
                projectType = hProject.getDefaultProjectType().toString();
            }
            Project project = new Project(hProject.getSlug(), hProject.getName(), projectType);
            project.setStatus(hProject.getStatus());
            project.getLinks(true).add(new Link(URI.create("p/" + hProject.getSlug()), "self",
                    MediaTypes.createFormatSpecificType(MediaTypes.APPLICATION_ZANATA_PROJECT, accept)));
            projectRefs.add(project);
        }
    }

    Type genericType = new GenericType<List<Project>>() {
    }.getGenericType();
    Object entity = new GenericEntity<List<Project>>(projectRefs, genericType);

    return Response.ok(entity).build();
}

From source file:org.zanata.service.impl.UserAccountServiceImpl.java

License:Open Source License

public void editUsername(String currentUsername, String newUsername) {
    Query updateQuery = session
            .createQuery("update HAccount set username = :newUsername where username = :currentUsername")
            .setParameter("newUsername", newUsername).setParameter("currentUsername", currentUsername);
    updateQuery.setComment("UserAccountServiceImpl.editUsername");
    updateQuery.executeUpdate();// w w  w . jav  a 2s .  c  om
    session.getSessionFactory().evictQueries(); // Because a Natural Id was
                                                // modified
}