[Hibernate-JIRA] Created: (HHH-7304) NaturalIdResolutionCache not correctly filled on first persist when @GeneratedValue-@Id
by Frank Schwarz (JIRA)
NaturalIdResolutionCache not correctly filled on first persist when @GeneratedValue-@Id
---------------------------------------------------------------------------------------
Key: HHH-7304
URL: https://hibernate.onjira.com/browse/HHH-7304
Project: Hibernate ORM
Issue Type: Bug
Components: core
Affects Versions: 4.1.3
Reporter: Frank Schwarz
{code:title=Employee.java|borderStyle=solid}
@Entity
public class Employee{
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) private long id;
@NaturalId(mutable = true) private String name;
@NaturalId(mutable = true) private String surname;
private String position;
}
{code}
{code:title=NaturalIdTest1.java|borderStyle=solid}
entityManager.getTransaction().begin();
Employee e = new Employee();
e.setSurname("Hans");
e.setName("Dampf");
e.setPosition("Junior");
entityManager.persist(e);
entityManager.getTransaction().commit();
Session session = entityManager.unwrap(Session.class);
Employee e2 = (Employee) session.byNaturalId(Employee.class)
.using("surname", "Hans")
.using("name", "Dampf")
.load();
System.out.println(e2);
{code}
{code:title=NaturalIdTest2.java|borderStyle=solid}
entityManager.getTransaction().begin();
Employee e = new Employee();
e.setSurname("Hans");
e.setName("Dampf");
e.setPosition("Junior");
entityManager.persist(e);
// this is the only difference
e.setPosition("Senior");
entityManager.getTransaction().commit();
Session session = entityManager.unwrap(Session.class);
Employee e2 = (Employee) session.byNaturalId(Employee.class)
.using("surname", "Hans")
.using("name", "Dampf")
.load();
System.out.println(e2);
{code}
The NaturalIdTest1 will issue an SQL statement for the find-by-natural-id-query; the NaturalIdTest2 does not.
Put a breakpoint into NaturalIdResolutionCache#cache(Serializable, Object[]) and watch the pk-parameter to be {{null}} on the first invocation and not {{null}} on the second invocation.
If the @Id-field is not @GeneratedValue, the first invocation of NaturalIdResolutionCache#cache will be already correct.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
11 years, 11 months
[Hibernate-JIRA] Created: (HHH-2448) Generate identical column aliases among cluster
by Loïc LEFEVRE (JIRA)
Generate identical column aliases among cluster
-----------------------------------------------
Key: HHH-2448
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2448
Project: Hibernate3
Type: Improvement
Components: query-sql
Versions: 3.2.2
Environment: Hibernate version: 3.2.2, 2.1.8
Database: Oracle 9.2.0.8
Reporter: Loïc LEFEVRE
Attachments: report_1.txt, report_2.txt
Among our weblogic cluster (12 instances), we can see that a query can have different column aliases.
Although all seems correct, when regarding database reports like StatsPack or Spotlight we can see that because of these different aliases, the reports are wrong. Indeed, a resource consuming query can see its associated report properties (cpu usage, buffer gets, number of executions...) divided by the number of weblogic instances of our cluster (i.e. divided by 12) thus preventing us to pinpoint the queries to look at.
On a 3 instances cluster, we can see this report:
REPORT#1: one statement with a poor number of buffer gets/execution is reported splitted in 3, see the alias generated for column DTO.CREATION_DATE
for example
On a 4 instances cluster, we can see this report:
REPORT#2: one statement responsible of the latch free/cache buffers chains wait events splitted in 4, note the column alias generated fordeffcashcy0_.BEST_EXPECTED_CY
More than confusing the DBAs about the same query with n different "faces", our reports don't show us all the queries to look at: indeed, in our "Top 50 queries", a lot of them are duplicates! Also the memory required in the SGA to store the queries, the execution plan and so on is increased...
Finally, although the column aliases can have up to 30 characters under Oracle, the limit is set to 10, why?
--
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
11 years, 11 months
[Hibernate-JIRA] Created: (HHH-5255) Bytecode instrumented byte[] lazy properties do not work
by Kyrill Alyoshin (JIRA)
Bytecode instrumented byte[] lazy properties do not work
--------------------------------------------------------
Key: HHH-5255
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5255
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.5.2
Environment: Hibernate-3.5.2, Oracle 10g
Reporter: Kyrill Alyoshin
Well, I have an entity that stores a byte[] property as a Blob.
@Lob
@Basic(optional = false, fetch = FetchType.LAZY)
public byte[] getContent() {
return content;
}
The content can be pretty large, so I marked it as lazy and to enable lazy property fetching I am instrumenting the class at build-time using org.hibernate.tool.instrument.javassist.InstrumentTask just as the documentation says.
However, when I call session.merge on this entity, I can get this stacktrace:
java.lang.ClassCastException: org.hibernate.intercept.LazyPropertyInitializer$1 cannot be cast to [B
at org.hibernate.type.AbstractLongBinaryType.toInternalFormat(AbstractLongBinaryType.java:46)
at org.hibernate.type.AbstractBynaryType.isEqual(AbstractBynaryType.java:134)
at org.hibernate.type.NullableType.isEqual(NullableType.java:233)
at org.hibernate.type.MutableType.replace(MutableType.java:60)
at org.hibernate.type.TypeFactory.replace(TypeFactory.java:548)
at org.hibernate.event.def.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:495)
at org.hibernate.event.def.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:423)
at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:234)
at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:84)
at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:859)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:843)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:847)
It seems to work fine on session.get()
I think it is a bug.
--
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
11 years, 11 months