[hibernate-issues] [Hibernate-JIRA] Updated: (HSEARCH-682) Add tests for DSL handling fieldBridge for @IndexEmbedded fields
Sanne Grinovero (JIRA)
noreply at atlassian.com
Wed Feb 8 07:05:13 EST 2012
[ https://hibernate.onjira.com/browse/HSEARCH-682?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sanne Grinovero updated HSEARCH-682:
------------------------------------
Description:
Changed this to "add test" rather than bug as it actually works fine.
Original description:
Discussed in https://forum.hibernate.org/viewtopic.php?f=9&t=1009440, "Re: Correct to use ignoreFieldBridge for "subentity.field" DSL?".
I find I have to set ignoreFieldBridge when querying for a field indexed using @IndexEmbedded, i.e.:
{code}@Entity
class CategoryEntity {
@Column(name="lft")
@Field(name="left", index=Index.UN_TOKENIZED, store=Store.YES)
@FieldBridge(impl=PadNumberBridge.class,
params = { @Parameter(name="pad", value="4") }
)
private int left;
... same for 'right' ...
}
@Entity
class ItemEntity {
@IndexedEmbedded(depth=1)
private CategoryEntity category;
}{code}
results in fields for ItemEntity being stored in the Lucene index like:
{code}
category.left = 0004
category.right = 0012
{code}
To query for these, I cannot do:
{code}
qb.range().onField("category.left").above(4).createQuery()
{code}
I get an exception saying it doesn't know what FieldBridge to use for "category.left". Instead, I can do:
{code}
qb.range().onField("category.left").ignoreFieldBridge().above(4).createQuery()
{code}
but the 'value' is no longer padded according to the FieldBridge that was specified in CategoryEntity for its 'left' attribute, I have to pass value as e.g. "0004".
It would be good to mention this situation in the documentation (5.1.2. "Building a Lucene query with the Hibernate Search query DSL"), at least to specify that it is/isn't supported, so that people attempting this kind of @IndexEmbedded mapping know how to safely build a query for such fields.
was:
Discussed in https://forum.hibernate.org/viewtopic.php?f=9&t=1009440, "Re: Correct to use ignoreFieldBridge for "subentity.field" DSL?".
I find I have to set ignoreFieldBridge when querying for a field indexed using @IndexEmbedded, i.e.:
{code}@Entity
class CategoryEntity {
@Column(name="lft")
@Field(name="left", index=Index.UN_TOKENIZED, store=Store.YES)
@FieldBridge(impl=PadNumberBridge.class,
params = { @Parameter(name="pad", value="4") }
)
private int left;
... same for 'right' ...
}
@Entity
class ItemEntity {
@IndexedEmbedded(depth=1)
private CategoryEntity category;
}{code}
results in fields for ItemEntity being stored in the Lucene index like:
{code}
category.left = 0004
category.right = 0012
{code}
To query for these, I cannot do:
{code}
qb.range().onField("category.left").above(4).createQuery()
{code}
I get an exception saying it doesn't know what FieldBridge to use for "category.left". Instead, I can do:
{code}
qb.range().onField("category.left").ignoreFieldBridge().above(4).createQuery()
{code}
but the 'value' is no longer padded according to the FieldBridge that was specified in CategoryEntity for its 'left' attribute, I have to pass value as e.g. "0004".
It would be good to mention this situation in the documentation (5.1.2. "Building a Lucene query with the Hibernate Search query DSL"), at least to specify that it is/isn't supported, so that people attempting this kind of @IndexEmbedded mapping know how to safely build a query for such fields.
Priority: Minor (was: Major)
Affects Version/s: (was: 3.3.0.Final)
Fix Version/s: 4.1.0.Beta2
Issue Type: Task (was: New Feature)
Summary: Add tests for DSL handling fieldBridge for @IndexEmbedded fields (was: DSL cannot handle fieldBridge for @IndexEmbedded fields)
> Add tests for DSL handling fieldBridge for @IndexEmbedded fields
> ----------------------------------------------------------------
>
> Key: HSEARCH-682
> URL: https://hibernate.onjira.com/browse/HSEARCH-682
> Project: Hibernate Search
> Issue Type: Task
> Components: query
> Environment: Hibernate 3.6.0, HSearch 3.3.0, Mysql 5.1.52.
> Reporter: Nick Fenwick
> Assignee: Davide D'Alto
> Priority: Minor
> Fix For: 4.1.0.Beta2
>
> Attachments: HSEARCH-682-unittest1.tgz
>
>
> Changed this to "add test" rather than bug as it actually works fine.
> Original description:
> Discussed in https://forum.hibernate.org/viewtopic.php?f=9&t=1009440, "Re: Correct to use ignoreFieldBridge for "subentity.field" DSL?".
> I find I have to set ignoreFieldBridge when querying for a field indexed using @IndexEmbedded, i.e.:
> {code}@Entity
> class CategoryEntity {
> @Column(name="lft")
> @Field(name="left", index=Index.UN_TOKENIZED, store=Store.YES)
> @FieldBridge(impl=PadNumberBridge.class,
> params = { @Parameter(name="pad", value="4") }
> )
> private int left;
> ... same for 'right' ...
> }
> @Entity
> class ItemEntity {
> @IndexedEmbedded(depth=1)
> private CategoryEntity category;
> }{code}
> results in fields for ItemEntity being stored in the Lucene index like:
> {code}
> category.left = 0004
> category.right = 0012
> {code}
> To query for these, I cannot do:
> {code}
> qb.range().onField("category.left").above(4).createQuery()
> {code}
> I get an exception saying it doesn't know what FieldBridge to use for "category.left". Instead, I can do:
> {code}
> qb.range().onField("category.left").ignoreFieldBridge().above(4).createQuery()
> {code}
> but the 'value' is no longer padded according to the FieldBridge that was specified in CategoryEntity for its 'left' attribute, I have to pass value as e.g. "0004".
> It would be good to mention this situation in the documentation (5.1.2. "Building a Lucene query with the Hibernate Search query DSL"), at least to specify that it is/isn't supported, so that people attempting this kind of @IndexEmbedded mapping know how to safely build a query for such fields.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list