[Hibernate-JIRA] Created: (HCANN-17) SecondaryTable JoinColumn cannot reference a non primary key
by Krashan Brahmanjara (JIRA)
SecondaryTable JoinColumn cannot reference a non primary key
------------------------------------------------------------
Key: HCANN-17
URL: http://opensource.atlassian.com/projects/hibernate/browse/HCANN-17
Project: Hibernate Commons Annotations
Issue Type: Bug
Affects Versions: 3.1.0.GA
Environment: Hibernate libraries added to jboss-6.0.0.20100216-M2(3.5) and jboss-5.1.0.GA(3.3.1) used with postgresql-8.3.7-1 database and jdbc driver postgresql-8.3-603.jdbc4.jar
Reporter: Krashan Brahmanjara
Hibertate annotations reject correct annotations with an error
Full exception
org.hibernate.AnnotationException: SecondaryTable JoinColumn cannot reference a non primary key
at org.hibernate.cfg.annotations.TableBinder.bindFk(TableBinder.java:243)
at org.hibernate.cfg.annotations.EntityBinder.bindJoinToPersistentClass(EntityBinder.java:520)
at org.hibernate.cfg.annotations.EntityBinder.createPrimaryColumnsToSecondaryTable(EntityBinder.java:510)
at org.hibernate.cfg.annotations.EntityBinder.finalSecondaryTableBinding(EntityBinder.java:441)
at org.hibernate.cfg.SecondaryTableSecondPass.doSecondPass(SecondaryTableSecondPass.java:25)
Example
Three entity, two connected to main 'dokument' by their id columns
@Entity
@Table(name = "dokument")
@SecondaryTables(value = {
@SecondaryTable(name = "dokument_status", pkJoinColumns = @PrimaryKeyJoinColumn(name = "id_status", referencedColumnName = "id_status")),
@SecondaryTable(name = "typ_dok", pkJoinColumns = @PrimaryKeyJoinColumn(name = "id_type", referencedColumnName = "id_type")) })
public class PosrDokument implements Serializable {
@Id
@Column(name="id_dokumentu", unique=true, nullable=false)
private int id_dokumentu;
@Column(name = "status", table = "dokument_status", nullable = false, insertable = false, updatable = false)
private String status;
@Column(name = "name", table = "typ_dok", nullable = false, insertable = false, updatable = false)
private String name;
(...)
--
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
12 years, 1 month
[Hibernate-JIRA] Created: (HHH-2831) Native SQL queries with addJoin or <return-join/> return object arrays instead of single Entities
by Jeremy Grodberg (JIRA)
Native SQL queries with addJoin or <return-join/> return object arrays instead of single Entities
-------------------------------------------------------------------------------------------------
Key: HHH-2831
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2831
Project: Hibernate3
Issue Type: Bug
Components: query-sql
Affects Versions: 3.2.5, 3.2.4
Environment: Hibernate 3.2.4.ga and 3.2.5.ga with hsqldb on Win XP
Reporter: Jeremy Grodberg
Attachments: NativeSQLQueriesTest.patch
Although the documentation is not crystal clear, I read it to say that using addJoin should eagerly fetch an associated object but should NOT return it as a separate value. In section 16.1.3. "Handling associations and collections" of the online documentation it says: "It is possible to eagerly join in the Dog to avoid the possible extra roundtrip for initializing the proxy. This is done via the addJoin() method, which allows you to join in an association or collection." This comes BEFORE the section on returning multiple entities, so I say the documentation at least implies it will only return a single entity at the top level. Also, if the intention is to return multiple entities, addEntity() works fine for that, so what then would be the difference of addJoin()? If I'm wrong about what addJoin() should do, please clarify that in the documentation and also clarify how, if it is possible, one could eagerly fetch the association without changing the return type of the quer
y.
I have reproduced this problem in the Hibernate JUnit tests in 3.2.4.ga and 3.2.5.ga, specifically NativeSQLQueriesTest.testSQLQueryInterface().
I'm attaching a patch to the Hibernate junit test org.hibernate.test.sql.hand.query.NativeSQLQueriesTest.java released in 3.2.5.ga that adds a test to ensure that a query with addJoin only returns a (list of) entities, not a list of Object arrays containing entities. Currently, the assertion fails because instead of returning a list of Organizations we get a list of Object[3] = { Organization, Employment, Person }, which is exactly what we get when the addJoin()s are replaced with appropriate addEntity() calls.
--
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
12 years, 1 month
[Hibernate-JIRA] Created: (HSEARCH-1048) More than one DocumentId found while only one is declared
by Sanne Grinovero (JIRA)
More than one DocumentId found while only one is declared
---------------------------------------------------------
Key: HSEARCH-1048
URL: https://hibernate.onjira.com/browse/HSEARCH-1048
Project: Hibernate Search
Issue Type: Bug
Components: mapping
Affects Versions: 4.1.0.Beta1
Reporter: Sanne Grinovero
All tests using entity org.hibernate.search.test.embedded.depth.PersonWithBrokenSocialSecurityNumber fail occasionally on Windows with Java7
- org.hibernate.search.test.embedded.depth.DocumentIdContainedInTest.testCorrectDepthIndexed
- org.hibernate.search.test.engine.UsingIdentifierRollbackTest.testEntityDeletionWithoutIdentifier
- org.hibernate.search.test.engine.UsingIdentifierRollbackTest.testRolledBackIdentifiersOnUnusualDocumentId
All show the same stacktrace:
{quote}
04:30:49,940 (main) DEBUG ConfigContext:307 - Setting Lucene compatibility to Version LUCENE_CURRENT
04:30:49,940 (main) DEBUG ConfigContext:209 - Using default similarity implementation: org.apache.lucene.search.DefaultSimilarity
04:30:49,940 (main) DEBUG LuceneIndexingParameters:94 - Set index writer parameter max_buffered_docs to value : 1000
04:30:49,940 (main) DEBUG LuceneIndexingParameters:94 - Set index writer parameter merge_factor to value : 100
04:30:49,940 (main) DEBUG WorkspaceFactory:43 - Starting workspace for index org.hibernate.search.test.embedded.depth.PersonWithBrokenSocialSecurityNumber using an exclusive index strategy
04:30:49,940 (main) INFO AvroSerializationProvider:73 - HSEARCH000079: Serialization protocol version 1.0
04:30:49,940 (main) DEBUG DocumentBuilderIndexedEntity:334 - Found JPA id and using it as document id
org.hibernate.search.SearchException: More than one @DocumentId specified on entity org.hibernate.search.test.embedded.depth.PersonWithBrokenSocialSecurityNumber
at org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.checkDocumentId(DocumentBuilderIndexedEntity.java:247)
at org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.documentBuilderSpecificChecks(DocumentBuilderIndexedEntity.java:237)
at org.hibernate.search.engine.spi.AbstractDocumentBuilder.initializeMemberLevelAnnotations(AbstractDocumentBuilder.java:462)
at org.hibernate.search.engine.spi.AbstractDocumentBuilder.initializeClass(AbstractDocumentBuilder.java:367)
at org.hibernate.search.engine.spi.AbstractDocumentBuilder.<init>(AbstractDocumentBuilder.java:151)
at org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.<init>(DocumentBuilderIndexedEntity.java:178)
at org.hibernate.search.spi.SearchFactoryBuilder.initDocumentBuilders(SearchFactoryBuilder.java:396)
at org.hibernate.search.spi.SearchFactoryBuilder.buildNewSearchFactory(SearchFactoryBuilder.java:220)
at org.hibernate.search.spi.SearchFactoryBuilder.buildSearchFactory(SearchFactoryBuilder.java:144)
at org.hibernate.search.event.impl.FullTextIndexEventListener.initialize(FullTextIndexEventListener.java:129)
at org.hibernate.search.hcore.impl.HibernateSearchIntegrator.integrate(HibernateSearchIntegrator.java:82)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:294)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1737)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1775)
at org.hibernate.search.test.SearchTestCase.buildConfiguration(SearchTestCase.java:230)
at org.hibernate.search.test.SearchTestCase.setUp(SearchTestCase.java:86)
at org.hibernate.search.test.SearchTestCase.runBare(SearchTestCase.java:394)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:243)
at junit.framework.TestSuite.run(TestSuite.java:238)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:119)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:101)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:103)
at $Proxy0.invoke(Unknown Source)
at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:150)
at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:91)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:69)
{quote}
Especially this is an interesting output:
*DEBUG DocumentBuilderIndexedEntity:334 - Found JPA id and using it as document id*
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 1 month
[Hibernate-JIRA] Created: (BVAL-198) Simplify creation of ConstraintViolationExceptions
by Gunnar Morling (JIRA)
Simplify creation of ConstraintViolationExceptions
--------------------------------------------------
Key: BVAL-198
URL: http://opensource.atlassian.com/projects/hibernate/browse/BVAL-198
Project: Bean Validation
Issue Type: Improvement
Components: spec-general
Affects Versions: 1.1
Reporter: Gunnar Morling
javax.validation.ConstraintViolationException wraps a set of constraint violations, currently in the following form:
Set<ConstraintViolation<?>> constraintViolations
As the exception's constructors have a parameter of the same type, instantiating it is not as easy as expected:
Validator validator = ...;
DomainObject domainObject = new DomainObject();
Set<ConstraintViolation<DomainObject>> constraintViolations = validator.validate(domainObject);
//compiler error: ("The constructor ConstraintViolationException(Set<ConstraintViolation<DomainObject>>) is undefined")
throw new ConstraintViolationException(constraintViolations);
//this works
throw new ConstraintViolationException(new HashSet<ConstraintViolation<?>>(constraintViolations));
This problem can be solved by changing the collection type to
Set<? extends ConstraintViolation<?>>
The exception then would read as follows:
public class ConstraintViolationException extends ValidationException {
private final Set<? extends ConstraintViolation<?>> constraintViolations;
public ConstraintViolationException(String message, Set<? extends ConstraintViolation<?>> constraintViolations) {
super( message );
this.constraintViolations = constraintViolations;
}
public ConstraintViolationException(Set<? extends ConstraintViolation<?>> constraintViolations) {
super();
this.constraintViolations = constraintViolations;
}
public Set<ConstraintViolation<?>> getConstraintViolations() {
return new HashSet<ConstraintViolation<?>>(constraintViolations);
}
}
This makes the exception easier to use for producers, while maintaining simplicity for clients (since getConstraintViolations() still returns a Set<ConstraintViolation<?>>, clients don't have to do deal with the bound wildcard expression).
--
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
12 years, 1 month
[Hibernate-JIRA] Created: (HHH-6127) Wrong save or read unicode value on @Lob String field in PostgreSQL 8.4
by Mihail Slobodyanuk (JIRA)
Wrong save or read unicode value on @Lob String field in PostgreSQL 8.4
-----------------------------------------------------------------------
Key: HHH-6127
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6127
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.6.3
Environment: PostgreSQL 8.4.5 on Ubuntu 32, Hibernate 3.6.0 - 3.6.3, jdbc driver: postgresql-8.3-603.jdbc3
Reporter: Mihail Slobodyanuk
Priority: Critical
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.url">jdbc:postgresql://localhost/test</property>
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="hibernate.connection.username">postgres</property>
<property name="hibernate.connection.password">postgres</property>
<property name="hbm2ddl.auto">update</property>
<property name="hibernate.connection.charSet">UTF-8</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.current_session_context_class">thread</property>
</session-factory>
</hibernate-configuration>
@Entity
public class ReportTemplate{
@Id
@GeneratedValue
private Integer id;
@Lob
private String body;
...
}
At save (or at read) operation with 'body' field value is broken. In DB stored Blob's OID.
The next code throw AssertionError:
String str="Русский текст";//Unicode string
rt = new ReportTemplate();
rt.setBody(str);
Serializable id = hsm.getSession().save(rt);
hsm.commit();
hsm.getSession().clear();
rt = (ReportTemplate) hsm.getSession().get(ReportTemplate.class, id);
assert str.equals(rt.getBody());
--
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
12 years, 1 month