SQL : Generic access to schema metadata in Q-types

Bug #596625 reported by Timo Westkämper
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Querydsl
Fix Released
Undecided
Unassigned

Bug Description

Table metadata like columns, primary keys, foreign keys, column constraints (size, nullability) should be provided in generic form in Q-types. On many jdbc drivers this information can be read from the metadata. This information can be used to automate some tasks with UI development.

Changed in querydsl:
status: New → In Progress
Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

Something like this maybe

interface RelationalEntity {

  PrimaryKey getPrimaryKey();

  Set<ForeignKey> getForeignKeys();

  Set<ForeignKey> getInverseForeignKeys();

}

In my opinion the column constraints could be bound to the properties as Bean Validation annotatios : http://people.redhat.com/~ebernard/validation/

This approach would also work with the Bean generation approach. For the BeanGeneration approach the annotations would be in the Bean :

class QProduct extends PEntity<Product> implements RelationalEntity{
  PNumber<Long> id;
  PString name;
}

@Table("PRODUCT")
class Product {

  @NotNull
  @Column("ID")
  Long id;

  @Size(max=256)
  @Column("NAME")
  String name;
}

or alternatively without the bean generation

@Table("PRODUCT")
class QProduct extends PEntity<Product> implements RelationalEntity{
  @NotNull
  PNumber<Long> id;

  @Size(max=256)
  PString name;
}

RelationalEntity could also be a subclass of PEntity :

public abstract class RelationEntity<E> extends PEntity<E> {

  public abstract PrimaryKey getPrimaryKey();

  public abstract Set<ForeignKey> getForeignKeys();

  public abstract Set<ForeignKey> getInverseForeignKeys();

}

What do you think?

Revision history for this message
Timo Westkämper (timo-westkamper) wrote :
Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

Added RelationalPath interface to Querydsl SQL generated Q-types :

public interface RelationalPath<T> extends EntityPath<T>{

    PrimaryKey<T> getPrimaryKey();

    Collection<ForeignKey<?>> getForeignKeys();

    Collection<ForeignKey<?>> getInverseForeignKeys();

}

The constraints part of schema metadata access will be continued in the Bean class code generation issue : https://bugs.launchpad.net/querydsl/+bug/604727

Changed in querydsl:
status: In Progress → Fix Committed
Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

Released in 1.9.0

Changed in querydsl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.