[Hibernate-JIRA] Created: (HHH-7202) No warning when declared targetEntity class doesn't match type of property
by Alex Cruise (JIRA)
No warning when declared targetEntity class doesn't match type of property
--------------------------------------------------------------------------
Key: HHH-7202
URL: https://hibernate.onjira.com/browse/HHH-7202
Project: Hibernate ORM
Issue Type: Bug
Components: entity-manager
Affects Versions: 4.1.1
Reporter: Alex Cruise
I had a mapping error like this:
@ManyToOne(targetEntity=Foo.class, fetch=FetchType.EAGER)
Bar bar;
The evidence for the error wound up being low-level and far removed:
java.lang.Exception: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of Foo.id
If there's any way that these correspondences could be validated earlier, it would be nice! Specifically, the type of the property should be assignable from the annotation's targetEntity class (or is it the opposite? I seem to be incapable of remembering which direction isAssignableFrom goes.)
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 4 months
[Hibernate-JIRA] Created: (HHH-6895) Easier annotation definitiopn of increment generator
by Steve Ebersole (JIRA)
Easier annotation definitiopn of increment generator
----------------------------------------------------
Key: HHH-6895
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6895
Project: Hibernate Core
Issue Type: Improvement
Reporter: Steve Ebersole
Priority: Minor
Fix For: 4.1.0
Useful in tests at least. Lot of duplication to specify an increment generator currently:
{code}
@Id
@GeneratedValue( generator="increment" )
@org.hibernate.annotations.GenericGenerator( name = "increment", strategy = "increment" )
public Long getId() { .. }
{code}
Combined with the fact that the increment generator does not accept configuration, would be nice to be able to just say:
{code}
@Id
@GeneratedValue( generator="increment" )
public Long getId() { .. }
{code}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 4 months
[Hibernate-JIRA] Created: (HSEARCH-1078) Dirty checking fails when searchable annotations are used on getter with 'non-standard' name
by Elmer van Chastelet (JIRA)
Dirty checking fails when searchable annotations are used on getter with 'non-standard' name
--------------------------------------------------------------------------------------------
Key: HSEARCH-1078
URL: https://hibernate.onjira.com/browse/HSEARCH-1078
Project: Hibernate Search
Issue Type: Bug
Components: mapping
Affects Versions: 4.1.0.CR2, 3.4.2
Reporter: Elmer van Chastelet
Attachments: TestEntityChangeWithDifferentGetterName.zip
A new issue, more detailed, as suggested in [HSEARCH-1076|https://hibernate.onjira.com/browse/HSEARCH-1076].
Hibernate search propagates entity changes to the search index(es) during an OnPostUpdate event. It checks if dirty properties are searchable, and if at least one dirty property is searchable, it builds a new document, replacing the one already in the index(es).
The 'checks if dirty properties are searchable'-part is currently failing when the following prerequisites are met:
- There is a java field F with getter method. e.g. private string _text;
- The getter method differs from the standard naming convention (e.g. getText for the field _text)
- The searchable annotation is placed on the getter method
- An entity is changed, where field F has a new value (e.g. _text is a dirty property).
It fails because it checks by using the meta data classes XClass and XProperty, and it uses XClass.getDeclaredProperties( XClass.ACCESS_PROPERTY ) to initially retrieve the names of the searchable entity properties (which are put in org.hibernate.search.engine.AbstractDocumentBuilder.PropertiesMetadata.fieldNameToPositionMap).
The problem is that XClass.getDeclaredProperties( XClass.ACCESS_PROPERTY ) returns the name extracted from the getter's method name. For the field _text used above, this means that dirty property '_text' is not linked to the extracted getter's method name 'text', and thus will not trigger a change to the search index(es).
This issue is in some form related to [HHH-775|https://hibernate.onjira.com/browse/HHH-755], stating that getters should comply with JavaBeans spec 1.01.
This specification says in section 7.1:
{quote} GetFoo and setFoo are simply example names. Accessor methods can have arbitrary names.
However for standard naming conventions for accessor methods see the design patterns de-
scribed in Section 8.3.
{quote}
So it doesn't force us to use the standard naming convention and I would argue that accessor methods may carry any name. (another example is the getter for a boolean flag, which is often in the form isEnabled())
Attached is a test case illustrating the problem.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 4 months
[Hibernate-JIRA] Created: (HSEARCH-1076) Simple entity changes not reflected in index
by Elmer van Chastelet (JIRA)
Simple entity changes not reflected in index
--------------------------------------------
Key: HSEARCH-1076
URL: https://hibernate.onjira.com/browse/HSEARCH-1076
Project: Hibernate Search
Issue Type: Bug
Components: engine
Affects Versions: 4.1.0.CR2, 3.4.2
Environment: Unit test on Ubuntu 11.10 x64
Reporter: Elmer van Chastelet
I was unable to find a unit test which tests if an entity change on a searchable String field (probably also other types) is reflected in the index. That's probably the reason I came across this serious issue.
I have changed an existing test to see if my expectations were true, and indeed: solely changing a String property (searchable) of an entity won't trigger an update to the index.
I will add a unit test for this particular case. For now, the failing code from an altered existing test:
{code:title=snippet from altered NestedEmbeddedTest.java}
s.clear();
tx = s.beginTransaction();
product = ( Product ) s.get( Product.class, product.getId() );
product.setNwField("value1");
tx.commit();
s.clear();
session = Search.getFullTextSession( s );
tx = s.beginTransaction();
QueryParser parser2 = new QueryParser( TestConstants.getTargetLuceneVersion(), "nwField", TestConstants.standardAnalyzer );
query = parser2.parse( "value1" );
result = session.createFullTextQuery( query, Product.class ).list();
assertEquals( "change on simple string field not reflected in root index", 1, result.size() );
tx.commit();
{code}
{code:title=addition to Product.java}
@Field(store = Store.YES)
private String nwField;
public String getNwField(){
return nwField;
}
public void setNwField(String fld){
nwField = fld;
}
{code}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 4 months