[Hibernate-JIRA] Created: (HHH-2769) Getting the following Exception. net.sf.hibernate.MappingException: Unknown entity class: java.lang.Boolean
by Suresh Gopalakrishnan (JIRA)
Getting the following Exception. net.sf.hibernate.MappingException: Unknown entity class: java.lang.Boolean
--------------------------------------------------------------------------------------------------------------------
Key: HHH-2769
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2769
Project: Hibernate3
Issue Type: Bug
Environment: Spring + Hibernate
Reporter: Suresh Gopalakrishnan
Priority: Blocker
Getting the following error, while trying to fetch the records from a table.
net.sf.hibernate.MappingException: Unknown entity class: java.lang.Boolean
at net.sf.hibernate.impl.SessionFactoryImpl.getPersister(SessionFactoryI
mpl.java:347)
at net.sf.hibernate.impl.SessionImpl.getClassPersister(SessionImpl.java:
2710)
at net.sf.hibernate.impl.SessionImpl.getPersister(SessionImpl.java:2717)
at net.sf.hibernate.impl.SessionImpl.getEntityIdentifierIfNotUnsaved(Ses
sionImpl.java:2779)
at net.sf.hibernate.type.EntityType.getIdentifier(EntityType.java:66)
at net.sf.hibernate.type.EntityType.isDirty(EntityType.java:139)
at net.sf.hibernate.type.TypeFactory.findDirty(TypeFactory.java:225)
at net.sf.hibernate.persister.AbstractEntityPersister.findDirty(Abstract
EntityPersister.java:276)
at net.sf.hibernate.impl.SessionImpl.flushEntity(SessionImpl.java:2528)
at net.sf.hibernate.impl.SessionImpl.flushEntities(SessionImpl.java:2478
)
at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:22
80)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2259)
at org.springframework.orm.hibernate.HibernateAccessor.flushIfNecessary(
HibernateAccessor.java:214)
at org.springframework.orm.hibernate.HibernateTemplate.execute(Hibernate
--
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, 5 months
[Hibernate-JIRA] Commented: (ANN-252) AnnotationConfiguration silently ignores classes that are annotated with wrong Entity, or not annotated.
by Michael Bergens (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-252?page=co... ]
Michael Bergens commented on ANN-252:
-------------------------------------
This issue is marked as fixed as of 3.3.0.GA but I still see this problem with 3.3.0.GA; to make things worse: with the wrong Entity the annotations config still fails silently, all I see as the result is the empty schema, both in the export .sql and in the database.
There is surely a workaround of setting up the imports straight, but it adds quite a bit to the learning curve and creates confusion.
It's no good that the javax.persistence annotations are named the same as the org.hibernate.annotation.*. Wonder whose fault is that, which was the first - the Sun or Hibernate to come up with these names?
With this name confusion, it seems like a good practice to always use full package specs like this:
@javax.persistence.Table(name = ..., uniqueConstraints = ...)
@org.hibernate.annotations.Table(appliesTo = ..., comment = ...)
public class ... {
...
Should this be highlighted in the documentation so new people don't waste time lost between these two packages?
> AnnotationConfiguration silently ignores classes that are annotated with wrong Entity, or not annotated.
> --------------------------------------------------------------------------------------------------------
>
> Key: ANN-252
> URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-252
> Project: Hibernate Annotations
> Issue Type: Improvement
> Components: binder
> Affects Versions: 3.1beta8
> Reporter: Damon Feldman
> Assignee: Emmanuel Bernard
> Fix For: 3.3.0.ga
>
> Original Estimate: 1 hour
> Remaining Estimate: 1 hour
>
> If you import the wrong Entity (e.g. org.hibernate.annotation.Entity) in a persistent class, the class is ignored, but no logging or other notification is made of the issue.
> Recommend: adding a log statement:
> log.warn("The class" + annotatedClass.getName() +"does not have the proper annotation: " + Entity.class.getName());
> Here is the code that seems responsible:
> /**
> * Read a mapping from the class annotation metadata (JSR 175).
> *
> * @param persistentClass the mapped class
> * @return the configuration object
> */
> public AnnotationConfiguration addAnnotatedClass(Class persistentClass) throws MappingException {
> try {
> if ( persistentClass.isAnnotationPresent( Entity.class ) ) {
> annotatedClassEntities.put( persistentClass.getName(), persistentClass );
> }
> annotatedClasses.add( persistentClass );
> return this;
> }
> catch (MappingException me) {
> log.error( "Could not compile the mapping annotations", me );
> throw me;
> }
> }
--
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, 5 months
[Hibernate-JIRA] Created: (ANN-646) DefaultComponentSafeNamingStrategy leaves '.' in column names on collection of elements table when container has compound PK
by Michael Newcomb (JIRA)
DefaultComponentSafeNamingStrategy leaves '.' in column names on collection of elements table when container has compound PK
----------------------------------------------------------------------------------------------------------------------------
Key: ANN-646
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-646
Project: Hibernate Annotations
Issue Type: Bug
Reporter: Michael Newcomb
Priority: Trivial
Consider:
@Entity
public class Boy
{
@EmbeddedId
protected PK id;
@CollectionOfElements
protected Collection<Toy> toys;
protected Boy()
{
}
public Boy(String firstName, String lastName)
{
id = new PK(firstName, lastName);
}
public String getFirstName()
{
return id.getFirstName();
}
public String getLastName()
{
return id.getLastName();
}
public Collection<Toy> getToys()
{
return toys != null ? toys : (toys = new LinkedList<Toy>());
}
@Override
public int hashCode()
{
return id.hashCode();
}
@Override
public boolean equals(Object rhs)
{
return rhs == this || (rhs instanceof Boy && id.equals(((Boy) rhs).id));
}
@Override
public String toString()
{
return id.toString();
}
@Embeddable
public static class PK
implements Serializable
{
@Basic
protected String firstName;
@Basic
protected String lastName;
protected PK()
{
}
public PK(String firstName, String lastName)
{
this.firstName = firstName;
this.lastName = lastName;
}
public String getFirstName()
{
return firstName;
}
public String getLastName()
{
return lastName;
}
@Override
public int hashCode()
{
return lastName.hashCode();
}
@Override
public boolean equals(Object rhs)
{
return this == rhs ||
(rhs instanceof PK && firstName.equals(((PK) rhs).firstName) &&
lastName.equals(((PK) rhs).lastName));
}
@Override
public String toString()
{
return String.format("%s %s", firstName, lastName);
}
}
@Embeddable
public static class Toy
implements Serializable
{
@Basic
protected String name;
protected Toy()
{
}
public Toy(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
@Override
public int hashCode()
{
return name.hashCode();
}
@Override
public boolean equals(Object rhs)
{
return this == rhs || (rhs instanceof Toy && name.equals(((Toy) rhs).name));
}
@Override
public String toString()
{
return name;
}
}
}
public String foreignKeyColumnName(String propertyName, String propertyEntityName, String propertyTableName, String referencedColumnName)
{
String header = propertyName != null ? addUnderscores( propertyName ) : propertyTableName;
if ( header == null ) throw new AssertionFailure( "NamingStrategy not properly filled" );
return columnName( header + "_" + referencedColumnName );
}
because referencedColumnName comes in as id.firstName.
DefaultComponentSafeNamingStrategy could:
1. override columnName() and call addUnderscores(columnName) or
2. call addUnderscores(referencedColumnName)
Thanks,
Michael
--
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, 5 months
[Hibernate-JIRA] Commented: (HHH-1296) Non lazy loaded List updates done in wrong order, cause exception
by Dirk Lachowski (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1296?page=c... ]
Dirk Lachowski commented on HHH-1296:
-------------------------------------
Fails also with MaxDB/sapDB
> Non lazy loaded List updates done in wrong order, cause exception
> -----------------------------------------------------------------
>
> Key: HHH-1296
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1296
> Project: Hibernate3
> Issue Type: Bug
> Components: core
> Affects Versions: 3.0.5
> Environment: Hibernate 3.0.5 - any database (checked postgres 7/8, mysql 4 & 5, db2 v8)
> NOT using lazy loading - the tx's are wrapped by session beans, so lazy loading is not allowed.
> Reporter: David Birch
> Priority: Critical
> Attachments: listupdate_patch.txt, listupdate_patch.txt, listupdate_testcase.zip
>
>
> The logic behind list updates is not quite right, nor was it in v2 (only now i have a DBA who won't let up...)
> The scenario is:
> a bean with list property, and the list has a number of items in it (say 4, index 0-3), an item is then removed (say item at index 2), and the bean is requested to be saved.
> From what i can see in the SQL traces, the same statements are issues whe lazy loading is on or off, they are:
> [18/12/05 19:48:50:766 EST] 00000036 SystemOut O Hibernate: delete from TGE_CLIENT_POLICY where CLIENT_ID=? and POSITION=?
> [18/12/05 19:48:50:766 EST] 00000036 SystemOut O Hibernate: update TGE_CLIENT_POLICY set POLICY_NK=? where CLIENT_ID=? and POSITION=?
> So, i can only assume (as when this fails, the row with index 1 above the removed row is nuked!), hibernate removes the item at index 3, and then copies the value of the item at index 3 onto the row for item at index 2. Fair enough but...
> When i have lazy loading off, i get DB exceptions like
> Duplicate key or integrity constraint violation message from server: "Duplicate entry '1-999999' for key 1"
> so, there is some nasty in there, which is not updating the correct row - this has happened since 2.1.8 that i know of :(
> i will try & look @ the source, but won't get a chance until after xmas...
--
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, 5 months