[Hibernate-JIRA] Created: (HHH-2664) full join not working
by Fabio Tudone (JIRA)
full join not working
---------------------
Key: HHH-2664
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2664
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.2.4, 3.1.2
Environment: Any DB, tested on Windows
Reporter: Fabio Tudone
Attachments: test.jar
I get this error when trying to full join:
- an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
org.hibernate.AssertionFailure: undefined join type 23
at org.hibernate.hql.ast.util.JoinProcessor.toHibernateJoinType(JoinProcessor.java:68)
at org.hibernate.hql.ast.HqlSqlWalker.setImpliedJoinType(HqlSqlWalker.java:433)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.joinElement(HqlSqlBaseWalker.java:3157)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3067)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2945)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:688)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:544)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:228)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:160)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
at com.finantix.test.Main.main(Main.java:63)
--
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
17 years, 10 months
[Hibernate-JIRA] Commented: (ANN-9) Support interface inheritance mapping
by Paul Singleton Kossler (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-9?page=com.... ]
Paul Singleton Kossler commented on ANN-9:
------------------------------------------
I am curious as the state of this improvement. It is mentioned in the "Java Persistence with Hibernate "from Manning press. Though the last traffic on this was a year ago. This feature helps the community by reducing the complexity of the build environment as well as reducing the number of files to track per class.
@Entity can handle mapping an Interface as follows:
//-----------------
@Entity
public interface A {
@Transient
public B getB();
public void setB(B b);
@Transient
public C getC();
public void setC(C c);
}
public class B{}
public class C{}
//------------------------
In this case a a simple POJO getter/setter can be mapped with @Transient to denote that the
actual persistence mapping annotations are only on the abstract or concrete class that actually contains information to be persisted.
Since a Java interface is the same as a pure virtual class in C one could take this one step further and allow @Transient assignment at the Class level.
This would denote that this class is not a class it is an interface (Can be checked with a guard on compile)
This would allow the SessionManager to determine the type of Entity: Real or Reference for class and interfaces respectively.
I may be going down a side path in this thought process; however, the @org.hibernate.annotations.Entity could also have an addition attribute "interface" such that:
@org.hibernate.annotations.Entity(interface="true")
defaulting to false; will keep this inline with the JPA spec and as an extension of a class level annotation this makes the @Transient annotations redundant so the Interface could be mapped more simply too:
//-----------------
@Entity(interface="true")
public interface A {
public B getB();
public void setB(B b);
public C getC();
public void setC(C c);
}
public class B{}
public class C{}
//------------------------
I hope this helps out other developers.
If I am inaccurate on the forum/implementation level I do apologize. Unfortunately looking up the word "interface" with Hibernate and Java is ambiguous, making it difficult to narrow in on.
> Support interface inheritance mapping
> -------------------------------------
>
> Key: ANN-9
> URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-9
> Project: Hibernate Annotations
> Issue Type: Improvement
> Components: binder
> Affects Versions: 3.1beta3
> Reporter: Gili
> Attachments: hibernate3-annotations-3.1beta5-3896-3948.diff, hibernate3-annotations-3.1beta5-3896-4138.diff
>
>
> It should be possible to create a mapping with interfaces, as described by the documentation here: http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#inheritanc...
> Specifically right now it is impossible to annotate interfaces and according to HBX-231 even if you could @Entity is only meant to get used on classes so the question becomes "what do you annotate it with?"
> As I pointed out here http://forum.hibernate.org/viewtopic.php?p=2238824#2238824 the additional problem seems to be that XDoclet doesn't support interface annotation either (http://opensource.atlassian.com/projects/xdoclet/browse/XDT-1345) so I'm left without a workaround.
> I can't convert the interfaces to abstract classes because I implement multiple interfaces in my application and Java does not do multiple inheritance.
> If you know of a nice workaround, please let me know :)
--
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
17 years, 10 months
[Hibernate-JIRA] Created: (HHH-2996) Allow expression in a @JoinColumn for a composite foreign key
by Darren Bell (JIRA)
Allow expression in a @JoinColumn for a composite foreign key
-------------------------------------------------------------
Key: HHH-2996
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2996
Project: Hibernate3
Issue Type: New Feature
Affects Versions: 3.2.5
Environment: hibernate 3.2.5, db2/400 v5r4
Reporter: Darren Bell
I am mapping our Mapics COM history with hibernate and have been pretty successful so far, but have hit a stumbling block.
There is a table in Mapics that stores history comments for many different other tables, hence each table has a different foreign key.
The table is outlined below for those that don't know Mapics ;)
COL_NO NAME COL_TYPE LENGTH DP NULL DFT DEFAULT DESCRIPTION
1 GAAENB NUMERIC 2 0 N Y 0 Company number
2 GAGGNB NUMERIC 6 0 N Y 0 Invoice number
3 GAHYNB DECIMAL 7 0 N Y 0 Invoice sequence
4 GAKBNB DECIMAL 5 0 N Y 0 Comment line sequence number
5 GAAKCD CHAR 3 N Y ' ' Language code
6 GAAAD9 CHAR 1 N Y ' ' Internal print only?
7 GAHDTX CHAR 25 N Y ' ' Comment line text
8 GAHXCD CHAR 5 N Y ' ' Comment user reference
9 GADCCD CHAR 1 N Y ' ' Internal header type
10 GACVNB CHAR 7 N Y ' ' Quote/order number
11 GAK4NB DECIMAL 7 0 N Y 0 Shipment header number
12 GAAFAD DECIMAL 3 0 N Y 0 Shipment consolidate seq
13 GALCNB DECIMAL 7 0 N Y 0 Ship release sequence
14 GAAASZ DECIMAL 5 0 N Y 0 Kit release sequence
15 GAAAD2 DECIMAL 7 0 N Y 0 Special charge sequence #
16 GAAD1N CHAR 1 N Y ' ' Text line print control
To get the comments from the shipment release we use the following:
@OneToMany()
@JoinColumns ({
@JoinColumn(name=HistoricalComment.Columns.COMPANY_NUMBER, referencedColumnName=ShipRelease.Columns.COMPANY_NUMBER),
@JoinColumn(name=HistoricalComment.Columns.INTERNAL_HEADER_TYPE, referencedColumnName=ShipRelease.Columns.INTERNAL_HEADER_TYPE),
@JoinColumn(name=HistoricalComment.Columns.ORDER_NUMBER, referencedColumnName=ShipRelease.Columns.ORDER_NUMBER),
@JoinColumn(name=HistoricalComment.Columns.SHIPMENT_HEADER_NUMBER, referencedColumnName=ShipRelease.Columns.SHIPMENT_HEADER_NUMBER),
@JoinColumn(name=HistoricalComment.Columns.SHIP_RELEASE_SEQUENCE, referencedColumnName=ShipRelease.Columns.SHIP_RELEASE_SEQUENCE),
@JoinColumn(name=HistoricalComment.Columns.KIT_RELEASE_SEQUENCE, referencedColumnName=ShipRelease.Columns.KIT_RELEASE_SEQUENCE)
})
@Sort(type=SortType.NATURAL)
private SortedSet<HistoricalComment> historicalComments;
Which works well, but to the the comments for the ship header the following is needed
@OneToMany()
@JoinColumns ({
@JoinColumn(name=HistoricalComment.Columns.COMPANY_NUMBER, referencedColumnName=ShipHeader.Columns.COMPANY_NUMBER),
@JoinColumn(name=HistoricalComment.Columns.INTERNAL_HEADER_TYPE, referencedColumnName=ShipHeader.Columns.INTERNAL_HEADER_TYPE),
@JoinColumn(name=HistoricalComment.Columns.ORDER_NUMBER, referencedColumnName=ShipHeader.Columns.ORDER_NUMBER),
@JoinColumn(name=HistoricalComment.Columns.SHIPMENT_HEADER_NUMBER, referencedColumnName=ShipHeader.Columns.SHIPMENT_HEADER_NUMBER)
})
@Sort(type=SortType.NATURAL)
private SortedSet<HistoricalComment> historicalComments;
As you can see there are two keys missing on the second one to many. This has the undesired effect of retriving all the comments for the entire shipment, whether they are related to a relase, the header itself, or charge codes.
Now, what i'm suggesting is to allow an expression for one of the join colums. The following would solve the problem.
@OneToMany()
@JoinColumns ({
@JoinColumn(name=HistoricalComment.Columns.COMPANY_NUMBER, referencedColumnName=ShipRelease.Columns.COMPANY_NUMBER),
@JoinColumn(name=HistoricalComment.Columns.INTERNAL_HEADER_TYPE, referencedColumnName=ShipRelease.Columns.INTERNAL_HEADER_TYPE),
@JoinColumn(name=HistoricalComment.Columns.ORDER_NUMBER, referencedColumnName=ShipRelease.Columns.ORDER_NUMBER),
@JoinColumn(name=HistoricalComment.Columns.SHIPMENT_HEADER_NUMBER, referencedColumnName=ShipRelease.Columns.SHIPMENT_HEADER_NUMBER),
@JoinColumn(name=HistoricalComment.Columns.SHIP_RELEASE_SEQUENCE, expression=":shipReleaseSequence > 0"),
@JoinColumn(name=HistoricalComment.Columns.KIT_RELEASE_SEQUENCE, expression=":kitReleaseSequence = 0")
})
This would put the expressions into the join clause.
What do you think? Have i explained this well enough?
--
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
17 years, 10 months
[Hibernate-JIRA] Created: (ANN-689) @JoinColumn not quoted for Oracle dialect
by Earnie Dyke (JIRA)
@JoinColumn not quoted for Oracle dialect
-----------------------------------------
Key: ANN-689
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-689
Project: Hibernate Annotations
Issue Type: Bug
Affects Versions: 3.2.1
Environment: Oracle 10g XE
Reporter: Earnie Dyke
Within an @Entity I have the following:
@ManyToOne(cascase = {}, fetch = FecthType.Lazy)
@JoinColumn(name = "`PresentationId`") // Notice the backticks
public Presentation getPresentation() {
return this.presentation;
}
the generated SQL for a load is:
select ... from PRESENTATION presentati0_ left outer join CSESSION csessions1_ on presentati0_."Id"=csessions1_.PresentationId where ...
Notice that PresentationId in csessions1_.PresentationId is NOT quoted. This causes an exception from Oracle:
java.sql.SQLException: ORA-00904: "CSESSIONS1_"."PRESENTATIONID": invalid identifier.
I added the backticks to all @Column annotations and they work. Also PresentationId is not quoted in the SELECT list either.
Earnie!
--
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
17 years, 10 months
[Hibernate-JIRA] Created: (ANN-700) Hibernate's @NamedQuery always sets flushMode
by Luke Maurer (JIRA)
Hibernate's @NamedQuery always sets flushMode
---------------------------------------------
Key: ANN-700
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-700
Project: Hibernate Annotations
Issue Type: Bug
Affects Versions: 3.3.0.ga
Environment: Hibernate 3.2.4.sp1, MySQL 5
Reporter: Luke Maurer
Hibernate's own @NamedQuery annotation (i.e. @org.hibernate.annotations.NamedQuery)'s flushMode attribute is AUTO by default. This tripped us up recently when we found that our Seam conversation-scoped persistence context (having MANUAL flush mode) was flushing prematurely. The problem is, though, no value of flushMode is going to be correct, as the query will elsewhere be used with flush mode AUTO.
The workaround is, of course, to set the flush mode every time we use the query, but this would be cumbersome and error-prone (and I suspect would defeat the point of being able to set it in the annotation in the first place). In our case, we didn't really need the extra stuff in the Hibernate extension, so we went back to the JPA @NamedQuery. At any rate, this is a very surprising (and subtle) side effect of merely switching from @javax.persistence.NamedQuery to @org.hibernate.annotations.NamedQuery.
(Unfortunately, I don't know a good solution, since, for what must be really great reasons, annotation elements can't have null values ...)
--
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
17 years, 10 months
[Hibernate-JIRA] Created: (HHH-3169) 3.2.6 breaks implicit join for collections
by Michael Newcomb (JIRA)
3.2.6 breaks implicit join for collections
------------------------------------------
Key: HHH-3169
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3169
Project: Hibernate3
Issue Type: Bug
Components: query-hql
Affects Versions: 3.2.6
Reporter: Michael Newcomb
The implicit join query "Cat.by.kitten.name2" below works fine in 3.2.5, but will fail to initialize in 3.2.6:
import java.util.Set;
import java.util.HashSet;
import java.util.List;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Query;
@Entity
@NamedQueries(value = {
@NamedQuery(
name = "Cat.by.kitten.name",
query = "select c from Cat c inner join c.kittens as kitten with kitten.name=:name"),
@NamedQuery(
name = "Cat.by.kitten.name2",
query = "select c from Cat c where c.kittens.name=:name")
}
)
public class Cat
{
@Id
protected String name;
@OneToMany
protected Set<Cat> kittens = new HashSet<Cat>();
public Cat(String name)
{
this.name = name;
}
public Set<Cat> getKittens()
{
return kittens;
}
public static void main(String... args)
{
EntityManager entityManager;
entityManager.getTransaction().begin();
Cat mom = new Cat("mom1");
Cat kitten1 = new Cat("mom1.kitten1");
Cat kitten2 = new Cat("mom1.kitten2");
entityManager.persist(mom);
entityManager.persist(kitten1);
entityManager.persist(kitten2);
mom.getKittens().add(kitten1);
mom.getKittens().add(kitten2);
mom = new Cat("mom2");
kitten1 = new Cat("mom2.kitten1");
kitten2 = new Cat("mom2.kitten2");
entityManager.persist(mom);
entityManager.persist(kitten1);
entityManager.persist(kitten2);
mom.getKittens().add(kitten1);
mom.getKittens().add(kitten2);
entityManager.getTransaction().commit();
Query query = entityManager.createNamedQuery("Cat.by.kitten.name");
query.setParameter("name", "mom1.kitten1");
for (Cat cat : (List<Cat>) query.getResultList())
{
System.out.println(cat.name);
}
query = entityManager.createNamedQuery("Cat.by.kitten.name2");
query.setParameter("name", "mom1.kitten1");
for (Cat cat : (List<Cat>) query.getResultList())
{
System.out.println(cat.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
17 years, 10 months
[Hibernate-JIRA] Created: (ANN-653) Exception when unidirection OneToMany relation defined in Embeded class
by Jifeng Liu (JIRA)
Exception when unidirection OneToMany relation defined in Embeded class
-----------------------------------------------------------------------
Key: ANN-653
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-653
Project: Hibernate Annotations
Issue Type: Bug
Affects Versions: 3.3.0.ga
Environment: Hibernate Core 3.2.5.ga
Hibernate Annotations 3.3.0 GA
Hibernate EntityManager 3.3.1 GA
Reporter: Jifeng Liu
Attachments: src.zip
I got the following exception when I run the test case in attach file. It seems Hibernate throws Exception when unidirection OneToMany relation defined in Embeded class.
Exception in thread "main" org.hibernate.AnnotationException: Illegal attempt to define a @JoinColumn with a mappedBy as
sociation: htmlText.images
at org.hibernate.cfg.Ejb3JoinColumn.buildJoinColumn(Ejb3JoinColumn.java:152)
at org.hibernate.cfg.Ejb3JoinColumn.buildJoinColumns(Ejb3JoinColumn.java:127)
at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1178)
at org.hibernate.cfg.AnnotationBinder.fillComponent(AnnotationBinder.java:1731)
at org.hibernate.cfg.AnnotationBinder.bindComponent(AnnotationBinder.java:1665)
at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1544)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:733)
at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:498)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:277)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115)
at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1269)
at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:150)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:888)
at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:706)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:137)
at test.Test.run(Test.java:24)
at test.Test.main(Test.java:20)
--
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
17 years, 10 months