[Hibernate-JIRA] Created: (HV-390) Boolean composition of constraints
by Federico Mancini (JIRA)
Boolean composition of constraints
----------------------------------
Key: HV-390
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-390
Project: Hibernate Validator
Issue Type: New Feature
Components: engine
Reporter: Federico Mancini
Assignee: Hardy Ferentschik
By adding a built-in annotation @Bool (or some other name) with element values OR, ALLFALSE and AND (which would be the default) it would be possible to
compose constraints in a boolean fashion.
For example:
//Specify that at least one of the patterns must match
@Bool(OR)
@List({@Pattern(regexp="pat1"),@Pattern(regexp="pat2"),@Pattern(regexp="pat3"),@Pattern(regexp="pat4")})
@interface WhiteList{..}
//Specify that none of the patterns must match
@Bool(ALLFALSE)
@List({@Pattern(regexp="pat1"),@Pattern(regexp="pat2"),@Pattern(regexp="pat3"),@Pattern(regexp="pat4")})
@interface BlackList{..}
//At least on valid contact method must match
@Bool(OR)
@Email
@Address
@Phone
@interface ContactDetails{...}
This would greatly increase the type of new constraints that can be defined just by reusing some existing ones.
Possible extensions might be for example further operators like XOR (meaning exactly one of the constraints must hold) or similar.
It seems like it is possible to implement this feature by adding very little code to just a couple of classes, and adding the new @Bool annotation to the API.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 7 months
[Hibernate-JIRA] Commented: (HHH-1886) unexpected AST node from where (id1, id2) in ((1, 2), (3, 4))
by Paizo (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1886?page=c... ]
Paizo commented on HHH-1886:
----------------------------
seems it's supported in 3.5 (see improvement HHH-4907)... i just tried it out and i still have the same error
> unexpected AST node from where (id1,id2) in ((1,2), (3,4))
> ----------------------------------------------------------
>
> Key: HHH-1886
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1886
> Project: Hibernate Core
> Issue Type: Bug
> Components: query-hql
> Affects Versions: 3.1.2
> Environment: Hibernate 3.1.2 Postgres 8.1.2
> Reporter: Brian Cox
> Attachments: hql.zip
>
>
> ANSI SQL allows: WHERE ((id1, id2)) IN ((1,2), (3,4)); but the HQL parser throws org.hibernate.hql.ast.QuerySyntaxException (see stack trace below). I've fixed this by modifying hql.g and sql-gen.g (attached below). Note that these mods caused a NullPointerException due to use of LA(0) in weakKeywords() (see HHH-1885) that I worked around by adding LT(0) != null
> before the LA(0) call; however, this does NOT fix the underlying problem [the use of LA(0)]
> org.hibernate.hql.ast.QuerySyntaxException: unexpected AST node: {vector} [select new com.timestock.tess.data.objects.StatsAggregationData(b.id,b.user,b.transet,b.tranunit,b.userGroup,b.transetGroup,...) from com.timestock.tess.data.objects.StatsTranSetUserGroupInterval b where b.intervalStartTime >= :startTime and b.intervalStartTime < :endTime and (b.transet,b.userGroup) in ((0,0),(600000000000000030,600000000000000137))
> at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:59)
> at org.hibernate.hql.ast.QueryTranslatorImpl.generate(QueryTranslatorImpl.java:209)
> at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:178)
> at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:109)
> at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:75)
> at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:54)
> at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
> at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:134)
> at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:113)
> at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1602)
> at com.timestock.tess.util.StatisticsAggregation.getDatabaseRows(StatisticsAggregation.java:410)
> at com.timestock.tess.util.StatisticsAggregation.getDatabaseRows(StatisticsAggregation.java:334)
> at com.timestock.tess.util.StatisticsAggregation.getAggregatedRows(StatisticsAggregation.java:222)
> at com.timestock.tess.util.TranSetAggregation.AggregateGroup(TranSetAggregation.java:259)
> at com.timestock.tess.util.TranSetAggregation.AggregateGroupHourly(TranSetAggregation.java:69)
> at com.timestock.tess.services.processors.StatsProcessor.doIntervalAggregation(StatsProcessor.java:732)
> at com.timestock.tess.services.processors.StatsProcessor.doIntervalAggregations(StatsProcessor.java:705)
> at com.timestock.tess.services.processors.StatsProcessor.processStats(StatsProcessor.java:418)
> at com.timestock.tess.services.collectors.StatsCollector$StatisticsCollector.run(StatsCollector.java:559)
> at java.util.TimerThread.mainLoop(Timer.java:512)
> at java.util.TimerThread.run(Timer.java:462)
> Caused by: <AST>:0:0: unexpected AST node: {vector}
> at org.hibernate.hql.antlr.SqlGeneratorBase.inList(SqlGeneratorBase.java:3016)
> at org.hibernate.hql.antlr.SqlGeneratorBase.exoticComparisonExpression(SqlGeneratorBase.java:2831)
> at org.hibernate.hql.antlr.SqlGeneratorBase.comparisonExpr(SqlGeneratorBase.java:1203)
> at org.hibernate.hql.antlr.SqlGeneratorBase.booleanExpr(SqlGeneratorBase.java:851)
> at org.hibernate.hql.antlr.SqlGeneratorBase.booleanOp(SqlGeneratorBase.java:2541)
> at org.hibernate.hql.antlr.SqlGeneratorBase.booleanExpr(SqlGeneratorBase.java:831)
> at org.hibernate.hql.antlr.SqlGeneratorBase.whereExpr(SqlGeneratorBase.java:724)
> at org.hibernate.hql.antlr.SqlGeneratorBase.selectStatement(SqlGeneratorBase.java:184)
> at org.hibernate.hql.antlr.SqlGeneratorBase.statement(SqlGeneratorBase.java:117)
> at org.hibernate.hql.ast.QueryTranslatorImpl.generate(QueryTranslatorImpl.java:203)
> ... 19 more
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 7 months
[Hibernate-JIRA] Created: (HSEARCH-115) Add a default value for indexing null value
by Julien Brulin (JIRA)
Add a default value for indexing null value
-------------------------------------------
Key: HSEARCH-115
URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-115
Project: Hibernate Search
Issue Type: Improvement
Components: mapping
Reporter: Julien Brulin
Hi,
Null elements are not indexed by lucene then it's not easy to use a nullable property in lucene query.
I have a TagTranslation entity in my model with a nullable property language. In this case null is used as default language for tag translation.
Each translation may have many variations like synonyms.
Because I can specified a default value for null value in the @Field annotation like this @Field(index=Index.UN_TOKENIZED, store=Store.NO, default='null'), i can't search a cat tag with a default translation like this : +value:cat* +lang:null
<pre></code>
@Entity()
@Table(name="indexing_tag_trans")
@org.hibernate.annotations.Cache(usage=org.hibernate.annotations.CacheConcurrencyStrategy.READ_WRITE)
@Indexed
public class TagTranslation implements java.io.Serializable {
private static final long serialVersionUID = -1065316566731456110L;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@DocumentId
private Integer id;
@Field(index=Index.UN_TOKENIZED, store=Store.NO)
private String language;
@Field(index=Index.TOKENIZED, store=Store.YES)
private String value;
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY)
@org.hibernate.annotations.Fetch(org.hibernate.annotations.FetchMode.SUBSELECT)
@JoinColumn(name="translation_id")
@IndexedEmbedded
private List<TagVariation> variations = new LinkedList<TagVariation>();
public TagTranslation() { }
...
</code>
</pre>
What do you think about that ?
Ps: sorry for english write, i am a french guy.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 7 months