Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite some listing method from SQL to Hibernate #1174

Open
geektortoise opened this issue Nov 8, 2019 · 0 comments
Open

Rewrite some listing method from SQL to Hibernate #1174

geektortoise opened this issue Nov 8, 2019 · 0 comments
Labels

Comments

@geektortoise
Copy link
Member

In Grails, for the complex requests, when the dynamic finders are not enough, we use the "request by criteria" allowed by GORM & Hibernate
Example here :

In some requests, I changed from Hibernate to SQL String because I didn't succeed to use Hibernate with some specific constraints.

If there is a developer fluent with Hibernate, he can maybe resolve this ticket without a deep knowledge of Cytomine :

  1. The listing of Image Instance cannot be done (by me and my knowledge ) with Criteria and Hibernate because, I need to join the Image_instance and tag_domain_association tables on not secondary_key fields i.e. join the id of the main table image_instance to a free field domain_ident of the tag_domain_association table.
    There is no reference of image_instance into the tag object/table and vice versa.
    Find here the commit where I changed from Criteria to SQL to have a base of a Criteria request

  2. In the same way, in the job listing, I need to join the job table with the sec_user table with an intermediate user_job table AND sort on the username of the sec_user.
    If the problem of the "reverse join" (job has no reference to user_job, it is the reverse situation), has been solved by a Detached Criteria (see the commit), I need to return from a Criteria OR HQL request an Object with the Job attributes + other (here the username).

  3. Project listing and user listing are complex request with temporary table created during the request to join and sort on some values (user) or to join on postgresql view (project).

An Criteria or HQL seems better than SQL for security (SQL injection) and the result are objects than can be used by other methods without the need to be reloaded from DB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant