SQL : Generic access to schema metadata in Q-types
Bug #596625 reported by
Timo Westkämper
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 |
To post a comment you must log in.
Something like this maybe
interface RelationalEntity {
PrimaryKey getPrimaryKey();
Set<ForeignKey> getForeignKeys();
Set<ForeignKey> getInverseForei gnKeys( );
}
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> getInverseForei gnKeys( );
}
What do you think?