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

Factory interface for DML #354

Closed
TuomasKiviaho opened this issue Mar 8, 2013 · 8 comments
Closed

Factory interface for DML #354

TuomasKiviaho opened this issue Mar 8, 2013 · 8 comments
Milestone

Comments

@TuomasKiviaho
Copy link
Contributor

@TuomasKiviaho TuomasKiviaho commented Mar 8, 2013

QueryFactory is a great facade and it would nice if I could use similar mechanism to create DML clauses.

@timowest
Copy link
Member

@timowest timowest commented Mar 8, 2013

Subinterfaces and implementing classes of QueryFactory have DML support.

What changes are you requesting?

@timowest
Copy link
Member

@timowest timowest commented Mar 11, 2013

Closing, since DML functionality is already available in subinterfaces. Please reopen and elaborate if I misunderstood.

@timowest timowest closed this Mar 11, 2013
@TuomasKiviaho
Copy link
Contributor Author

@TuomasKiviaho TuomasKiviaho commented Mar 12, 2013

I reviewed the master and noticed that there's no common ancestor for Hibernate and JPA. This means similar situation that I had with JPQLSubQuery back in the day, where I can't truly be agnostic about what implementation I'm querying/modifying against. Since DML starting points are not (and should not be) present in QueryFactory, I was hoping for similar approach as stated below, so that BND tool doesn't get exited about hibernate internals when it sees them

public interface DMLClauseFactory<
   I extends InsertClause<?>, 
   U extends UpdateClause<?>, 
   D extends DeleteClause<?>> {
 public D delete(EntityPath<?> path);
 public U update(EntityPath<?> path);
 public I insert(EntityPath<?> path);
}

public JPAQueryFactory implements QueryFactory<...,..>, DMLClauseFactory<...,...,...> {
  ...
  public JPADeleteClause delete(EntityPath<?> path) {..}
  public JPAUpdateClause update(EntityPath<?> path) {..}
  public JPAInsertClause insert(EntityPath<?> path) {
    throw new UnsupportedOperationException();
  }
}

PS. Do you have current maven snapshots lying around in some repo.
PPS. To my surprise I noticed that the is no InsertClause implementation although I got the feeling from forums that there has been one at some point (https://groups.google.com/forum/#!topic/querydsl/PSYY9vNR7xc)

@timowest timowest reopened this Mar 12, 2013
@timowest
Copy link
Member

@timowest timowest commented Mar 12, 2013

The problem with DMLClauseFactory is that on the SQL side, delete, update and insert take an RelationalPath and for JPA and Hibernate there is no InsertClause.

My forum answer is misleading, there is no INSERT clause for JPQL so Querydsl doesn't have one either.

Maybe a direct common ancestor with the needed methods for the JPA related factory classes might be a better solution?

@TuomasKiviaho
Copy link
Contributor Author

@TuomasKiviaho TuomasKiviaho commented Mar 12, 2013

Common ancestor suits well my needs. In fact it would reduce nicely the noise currently caused by generics. (QueryFactory<? extends JPQLQuery, ? extends JPQLSubQuery> -> JPQLQueryFactory).

Just FYI: There is one for HQL (http://docs.jboss.org/hibernate/orm/4.1/devguide/en-US/html/ch11.html#d5e2637) so HibernateInsertClause might be possible. Not that I'd be needing it anytime soon.

I'd be already using the forthcoming release but the Maven SNAPSHOTs produced to Mysema's repo seem to be old and I can't find any newer ones.

@timowest
Copy link
Member

@timowest timowest commented Mar 12, 2013

There are no automated snapshots, 3.0.0.BETA2 is the newest release.

@timowest
Copy link
Member

@timowest timowest commented Mar 13, 2013

The new JPQLQueryFactory does the the job without a generic parameters.

@timowest
Copy link
Member

@timowest timowest commented Mar 21, 2013

Released in 3.0.0

@timowest timowest closed this Mar 21, 2013
@timowest timowest added this to the 3.0.0 milestone Apr 14, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants