Dialect support for SQL comments.
by Daniel Bell
Hi,
I have recently tried turning on SQL comments in hibernate 3.2.6.ga.
However, I found that our database (informix 7.31) did not support SQL
where the comment was at the start of the comment. Instead, the comment
needed to be after the SQL. For example:
/* not accepted by informix 7.31*/ select * from systables;
select * from systables /* accepted by informix 7.31*/
Because of this, I have added a method to the Dialect for adding comments:
/**
* Add a comment to the SQL string.
*
* @param sql StringBuffer holding the SQL.
* @param comment Comment to add to the SQL. May be null.
*/
public void addCommentToSql(StringBuffer sql, String comment) {
if (StringHelper.isNotEmpty(comment))
sql.insert(0, "/* " + comment + " */ ");
}
Thus, the default implementation provides the same functionality as
before. However, derived Dialects may override this method to add the
comment in a different location.
It is also possible to add additional comments in the derived Dialect.
In our case, we also add the Java thread ID.
I have included a complete patch for this change for hibernate 3.2.6.GA.
Please consider its inclusion in Hibernate.
Thanks,
Daniel.
15 years, 7 months
large hql queries holding classloader lock for too long in weblogic
by Unmesh joshi
Hi,
We had an issue in our project where large hql expressions holding on lock to ChangeAwareClassloader in weblogic.
We had an hql query which was like
select * from ClassA a where a.identifier = 'id1' or a.identifier='id2' or ..... a.identifier='id1000'.
This was certainly bad to have this big or expression, but an issue this caused in weblogic is something interesting.
Hibernate query engine processes each identifier in a query to see if its a Java Class. So for each one of ClassA, a.identifier etc it calls Class.forName, if NoClassDefFound exception is thrown, ReflectHelper.getConstantValue returns null.
Now the problem is, if the expression is huge, recursive calls to /NodeTraverser.visitDepthFirst create huge stack trace. While building ClassNotFoundException, system class loader gets stuck to build all this stack trace. Because weblogic/utils/classloaders/ChangeAwareClassLoader.loadClass method is synchronized, any other thread trying to load any other class is blocked. If the stack trace is huge and taking consideratble amount of time to create Exception object, the lock is held for that much time, blocking every other thread trying to any the class. It brought down our servers in test environment.
Is this a known issue in weblogic and hibernate? I know that building such a large expression is bad(and we have already changed the code which was doing that), but the way its blocking the classloader in weblogic is an issue I think.
Following is the thread dump.
"[STUCK] ExecuteThread: '9' for queue: 'weblogic.kernel.Default (self-tuning)'" id=614 idx=0x3f8 tid=15385 prio=1 alive, in native, daemon
at pthread_cond_wait@@GLIBC_2.3.2+170(:0)@0x318c008a7a
at vmtWaitUntilNotSoftSuspended+66(:0)@0x2a955e35c2
at find_codeinfo+138(:0)@0x2a955b032e
at cmFindStackCodeInfoWithHint+44(:0)@0x2a955b040e
at frameIterFindCodeInfo+19(:0)@0x2a9571b11f
at frameIterGetCurrentAndStep+130(:0)@0x2a9571b489
at jniFillInStackTrace+368(:0)@0x2a95630d25
at JVM_FillInStackTrace+9(:0)@0x2a95647661
at RJNI_jrockit_vm_Reflect_fillInStackTrace0+9(:0)@0x2a956f5983
at jrockit/vm/Reflect.fillInStackTrace0(Ljava/lang/Throwable;)V(Native Method)
at java/lang/Throwable.fillInStackTrace()Ljava/lang/Throwable;(Native Method)[optimized]
at java/lang/Throwable.<init>(Throwable.java:218)[optimized]
at java/lang/Exception.<init>(Exception.java:59)[inlined]
at java/lang/ClassNotFoundException.<init>(ClassNotFoundException.java:65)[optimized]
at java/net/URLClassLoader$1.run(URLClassLoader.java:200)[inlined]
at jrockit/vm/AccessController.doPrivileged(AccessController.java:255)[inlined]
at java/net/URLClassLoader.findClass(URLClassLoader.java:188)[optimized]
at java/lang/ClassLoader.loadClass(ClassLoader.java:306)[optimized]
^-- Holding lock: java/net/URLClassLoader@0x4993580[thin lock]
at java/lang/ClassLoader.loadClass(ClassLoader.java:299)[optimized]
^-- Holding lock: weblogic/utils/classloaders/GenericClassLoader@0x469e900[thin lock]
at java/lang/ClassLoader.loadClass(ClassLoader.java:251)[inlined]
at weblogic/utils/classloaders/GenericClassLoader.loadClass(GenericClassLoader.java:158)[optimized]
at weblogic/utils/classloaders/FilteringClassLoader.findClass(FilteringClassLoader.java:83)[inlined]
at weblogic/utils/classloaders/FilteringClassLoader.loadClass(FilteringClassLoader.java:68)[optimized]
at java/lang/ClassLoader.loadClass(ClassLoader.java:299)[optimized]
^-- Holding lock: weblogic/utils/classloaders/GenericClassLoader@0x4969138[thin lock]
at java/lang/ClassLoader.loadClass(ClassLoader.java:299)[inlined]
at java/lang/ClassLoader.loadClass(ClassLoader.java:251)[inlined]
at weblogic/utils/classloaders/GenericClassLoader.loadClass(GenericClassLoader.java:158)[inlined]
at weblogic/utils/classloaders/ChangeAwareClassLoader.loadClass(ChangeAwareClassLoader.java:35)[optimized]
^-- Holding lock: weblogic/utils/classloaders/ChangeAwareClassLoader@0x4915178[recursive]
at jrockit/vm/Classes.loadClassInternal(Classes.java:75)[optimized]
^-- Holding lock: weblogic/utils/classloaders/ChangeAwareClassLoader@0x4915178[fat lock]
at jrockit/vm/RNI.c2java(JJJJJ)V(Native Method)
at jrockit/vm/Classes.forName0(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;(Native Method)
at jrockit/vm/Classes.forName(Classes.java:125)[inlined]
at java/lang/Class.forName(Class.java:164)[inlined]
at org/hibernate/util/ReflectHelper.classForName(ReflectHelper.java:100)[inlined]
at org/hibernate/util/ReflectHelper.getConstantValue(ReflectHelper.java:122)[inlined]
at org/hibernate/hql/ast/QueryTranslatorImpl$JavaConstantConverter.handleDotStructure(QueryTranslatorImpl.java:569)[inlined]
at org/hibernate/hql/ast/QueryTranslatorImpl$JavaConstantConverter.visit(QueryTranslatorImpl.java:564)[optimized]
at org/hibernate/hql/ast/util/NodeTraverser.visitDepthFirst(NodeTraverser.java:40)[optimized]
Following is part of thread dump which shows a thread waiting for Classloader lock.
"[ACTIVE] ExecuteThread: '51' for queue: 'weblogic.kernel.Default (self-tuning)'" id=7096 idx=0x6f8 tid=7459 prio=5 alive, in native, blocked, daemon
-- Blocked trying to get lock: weblogic/utils/classloaders/ChangeAwareClassLoader@0x4915178[fat lock]
at pthread_cond_wait@@GLIBC_2.3.2+170(:0)@0x318c008a7a
at tsiWaitForSignalForever+58(:0)@0x2a957035b5
at tsiWaitForSignal+39(:0)@0x2a95703610
at tsiWaitForLockSignal+39(:0)@0x2a957036f6
at tsWaitForJavaLockSignal+31(:0)@0x2a957037a5
at RJNI_jrockit_vm_Threads_waitForUnblockSignal+14(:0)@0x2a956f7620
at jrockit/vm/Threads.waitForUnblockSignal()V(Native Method)
at jrockit/vm/Locks.fatLockBlockOrSpin(Locks.java:1674)[optimized]
at jrockit/vm/Locks.lockFat(Locks.java:1775)[optimized]
at jrockit/vm/Locks.monitorEnterSecondStageHard(Locks.java:1311)[optimized]
at jrockit/vm/Locks.monitorEnterSecondStage(Locks.java:1258)[optimized]
at weblogic/utils/classloaders/ChangeAwareClassLoader.loadClass(ChangeAwareClassLoader.java:35)[optimized]
at com/sun/org/apache/xerces/internal/impl/dv/ObjectFactory.findProviderClass(ObjectFactory.java:403)[inlined]
at com/sun/org/apache/xerces/internal/impl/dv/ObjectFactory.newInstance(ObjectFactory.java:354)[inlined]
at com/sun/org/apache/xerces/internal/impl/dv/DTDDVFactory.getInstance(DTDDVFactory.java:98)[optimized]
^-- Holding lock: java/lang/Class@0x4fba6b8[recursive]
at com/sun/org/apache/xerces/internal/impl/dv/DTDDVFactory.getInstance(DTDDVFactory.java:83)[inlined]
at com/sun/org/apache/xerces/internal/parsers/XML11Configuration.<init>(XML11Configuration.java:565)[inlined]
Thanks,
Unmesh
Make sure your wardrobe reflects the latest trends and styles in the world of fashion. Try it!
_________________________________________________________________
Drag n’ drop—Get easy photo sharing with Windows Live™ Photos.
http://www.microsoft.com/windows/windowslive/photos.aspx
15 years, 11 months
resend: RFC: implement criteria API query of collection-of-component and collection-of-value
by David Mansfield
[ I sent this about a week ago and haven't heard anything from anyone.
Can someone let me know if I'm barking up the right tree? ]
Hi All,
The attached patch, which is not quite ready for inclusion, but works
completely under light testing, implements the functionality
missing from the criteria API for querying collections that are not
collection-of-entity. (ie. fix the causes of 'collection is not an
association', (i.e first issue on 'Advanced Problems' faq)).
This needs some feedback and review. I have created issue
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3646 to
track the issue, but I've not yet received any feedback.
Implementation notes:
The main area of change is to the CriteriaQueryTranslator class. In
this class, we replace the 'criteriaEntityNames' map of Criteria =>
String with two maps, one mapping Criteria => CriteriaInfoProvider and
one mapping String (name) => CriteriaInfoProvider.
The new class, CriteriaInfoProvider is an interface/abstraction to the
functionality needed by the various entry points into the translator,
such as to retrieve the 'spaces', get the PropertyMapping etc.
There are 3 concrete implementations of CriteriaInfoProvider:
* EntityCriteriaInfoProvider: this is the functionality that was always
present in the translator, ie. use getEntityPersister() etc.
* ComponentCollectionInfoProvider: this is the functionality that
extends the api for collection-of-component. In this class, we have to
provide the collection 'spaces' and the 'collection persister', but we
also have to look in detail at the ComponentType to be able to resolve
property references off of the component.
* ScalarCollectionInfoProvider: this is the functionality the provides
the api for collection-of-value. The main thing here is we use the
SessionFactoryHelper (part of the HQL tree) to get the
CollectionPropertyMapping object for mapping the 'elements','indices'
etc. properties. There's at least one 'I have no idea what to put here'
method in this class.
There is substantial cruft in the patch for debugging, which will not be
part of the final implementation.
There is a crude hack in CriteriaJoinWalker which needs some expert
advice: the existing implementation was looking at some mysterious
'consumesEntityAlias' boolean, but I need to force the code to lookup
the alias from the translator every time, or else it bypasses the alias
for the collection itself, and the SQL aliases are wrong.
There is also a completely separate bugfix wedged in here, which needs
to be extracted to its own issue/patch. The changes to JoinWalker are
necessary and correct: if the last association will not generate any
selectFragment, then the implementation adds an extraneous ", " to the
generated string.
Looking forward to your feedback and working together to get this into
the tree. Need info about test cases to create, documentation etc.
Thanks,
David Mansfield
Cobite, INC.
15 years, 11 months
About Search's Threadlocal and memory leak: automatic listener registration
by Sanne Grinovero
Hi all,
reading the code it appears the JIRA reporter is right: the static
ThreadLocal is using a WeakHashMap but the value
is holding a reference to the Configuration, which also happens to be the key.
(see SearchConfigurationFromHibernateCore 's constructor, called at
line 30 in ContextHolder)
So we could make a copy of this configuration object to break the
reference, but I would prefer
to remove the ThreadLocal completely: assuming we always have the
automatic registration in Search 3.1
as it depends on newest Annotations, my proposal is to:
1) In FullTextIndexEventListener.initialize() whe do nothing if
already initialized
2) Change EventListenerRegister to always REMOVE whatever additional
SearchListener if finds, to make sure there is only one instance.
The current EventListenerRegister semantic is not looking safe at the
moment anyway: if someone was to register a
FullTextIndexEventListener's
extension we end up with multiple Search listeners anyway.
As there is a TODO in FullTextIndexEventListener to "make it final as
soon as FullTextIndexCollectionEventListener is removed" I'd suggest
to also
3) make FullTextIndexEventListener final now
4) change the current FullTextIndexCollectionEventListener to a no-op
listener, eventually removing/replacing it in EventListenerRegister.
And not needed but I think would improve it more:
5A) change the current FullTextIndexEventListener no-arg constructor
to do nothing at initialize() to avoid unnecessary processing at
startup,
in case someone is still declaring it by configuration.
5B) add a 1-arg constructor to it, to be used by
EventListenerRegister, so that it's possible at last to have correct
final fields in FullTextIndexEventListener
to achieve a safe concurrent implementation (EventListenerRegister has
a reference to the configuration so can pass it directly to the
constructor);
IMHO this way the startup would get a nice cleanup: safe for
concurrency, no more ThreadLocal worries, no more unused
SearchFactories being
initialized.
what do you think?
Sanne
15 years, 11 months
[Fwd: Re: no support for retrieving a native generated identifier using a custom user type]
by Steve Ebersole
David, for some reason it never registered that Chris sent me this email
in private; I should have responded here on list.
I prefer the interface approach.
-
Steve Ebersole
Project Lead
http://hibernate.org
steve(a)hibernate.org
Principal Software Engineer
JBoss, a division of Red Hat
http://jboss.com
http://redhat.com
steve.ebersole(a)jboss.com
steve.ebersole(a)redhat.com
-------- Forwarded Message --------
> From: Steve Ebersole <steve(a)hibernate.org>
> To: Chris Webb <chris(a)hullomail.com>
> Subject: Re: no support for retrieving a native generated identifier
> using a custom user type
> Date: Thu, 04 Dec 2008 16:30:12 -0600
>
> The "more correct" solution is along the lines a contract to allow the
> type to handle this like you said. I'm thinking something like an
> optional interface for the type to publish that fact:
>
> public interface ResultSetIdentifierConsumer {
> public Serializable consumeIdentifier(ResultSet resultSet);
> }
>
> now IdentifierGeneratorFactory (called IdentifierGeneratorHelper now
> btw) can say:
>
> public static Serializable get(ResultSet rs, Type type) ... {
> if ( type instanceof ResultSetIdentifierConsumer ) {
> return ( ( ResultSetIdentifierConsumer )
> type ).consumeIdentifier( rs );
> }
>
> Class clazz = type.getReturnedClass();
> if ( clazz == Long.class ) {
> return new Long( rs.getLong( 1 ) );
> }
> else if ( clazz == Integer.class ) {
> return new Integer( rs.getInt( 1 ) );
> }
> else if ( clazz == Short.class ) {
> return new Short( rs.getShort( 1 ) );
> }
> else if ( clazz == String.class ) {
> return rs.getString( 1 );
> }
> else {
> throw ...
> }
> }
>
> and you can define a type :
>
> public class VxsContactIdLongType ... implements
> ResultSetIdentifierConsumer ... {
> public Serializable consumeIdentifier(ResultSet resultSet) {
> return new VxsContactIdLong( resultSet.getLong( 1 ) );
> }
> ...
> }
>
> --
>
> Steve Ebersole
> Project Lead
> http://hibernate.org
> steve(a)hibernate.org
>
> Principal Software Engineer
> JBoss, a division of Red Hat
> http://jboss.com
> http://redhat.com
> steve.ebersole(a)jboss.com
> steve.ebersole(a)redhat.com
>
>
> On Thu, 2008-11-27 at 01:42 +0000, Chris Webb wrote:
> > Steve,
> >
> > I've come up with a generic solution that makes the slight assumption
> > that any custom user type identifier that supports native generation
> > provides an appropriate constructor to take in the returned result set
> > field. The constructor is called using reflection in
> > org.hibernate.id.IdentifierGeneratorFactory.get(ResultSet rs, Type
> > type) as follows:
> >
> > public static Serializable get(ResultSet rs, Type type) throws
> > SQLException, IdentifierGenerationException {
> > Class clazz = type.getReturnedClass();
> > if ( clazz == Long.class ) {
> > return new Long( rs.getLong( 1 ) );
> > }
> > else if ( clazz == Integer.class ) {
> > return new Integer( rs.getInt( 1 ) );
> > }
> > else if ( clazz == Short.class ) {
> > return new Short( rs.getShort( 1 ) );
> > }
> > else if ( clazz == String.class ) {
> > return rs.getString( 1 );
> > }
> > else {
> > // >>>>>> START NEW LOGIC
> >
> > // Now check to see if the returned class wraps the
> > returned result
> > // set field. Assumes the returned class defines an
> > appropriate
> > // public constructor.
> > // TODO: Rather then assuming an appropriate constructor
> > and using
> > // reflection maybe the type should define a method that
> > takes a
> > // result set and returns the appropriate identifier type.
> >
> > Object identifierValue = null;
> >
> > try {
> > try {
> > Constructor<Serializable> constructor =
> > clazz.getConstructor(new Class[] { long.class});
> > identifierValue = new Long(rs.getLong(1));
> > return constructor.newInstance(new Object[]
> > { identifierValue });
> > } catch (NoSuchMethodException e) {
> > try {
> > Constructor<Serializable> constructor =
> > clazz.getConstructor(new Class[] { int.class});
> > identifierValue = new Integer(rs.getInt(1));
> > return constructor.newInstance(new Object[]
> > { identifierValue });
> > } catch (NoSuchMethodException e1) {
> > try {
> > Constructor<Serializable> constructor =
> > clazz.getConstructor(new Class[] { short.class});
> > identifierValue = new
> > Short(rs.getShort(1));
> > return constructor.newInstance(new
> > Object[] { identifierValue });
> > } catch (NoSuchMethodException e2) {
> > try {
> > Constructor<Serializable> constructor
> > = clazz.getConstructor(new Class[] { String.class});
> > identifierValue = rs.getString(1);
> > return constructor.newInstance(new
> > Object[] { identifierValue });
> > } catch (NoSuchMethodException e3) {
> > // Do nothing.
> > }
> > }
> > }
> > }
> > } catch (SecurityException e) {
> > throw new IdentifierGenerationException("Failed to
> > instantiate identifier class '" + clazz + "' with identifier value '"
> > + identifierValue + "'", e);
> > } catch (IllegalArgumentException e) {
> > throw new IdentifierGenerationException("Failed to
> > instantiate identifier class '" + clazz + "' with identifier value '"
> > + identifierValue + "'", e);
> > } catch (InstantiationException e) {
> > throw new IdentifierGenerationException("Failed to
> > instantiate identifier class '" + clazz + "' with identifier value '"
> > + identifierValue + "'", e);
> > } catch (IllegalAccessException e) {
> > throw new IdentifierGenerationException("Failed to
> > instantiate identifier class '" + clazz + "' with identifier value '"
> > + identifierValue + "'", e);
> > } catch (InvocationTargetException e) {
> > throw new IdentifierGenerationException("Failed to
> > instantiate identifier class '" + clazz + "' with identifier value '"
> > + identifierValue + "'", e);
> > }
> >
> > // <<<<<< END NEW LOGIC
> >
> > throw new IdentifierGenerationException( "this id
> > generator generates long, integer, short or string or classes that
> > wrap those types" );
> > }
> >
> > }
> >
> > I've left a comment in HB-92 to request the issue to be reopened and
> > the change described applied. Is the assumption I'm making acceptable?
> > Looking forward to hearing your comments.
> >
> > cheers,
> > chris
> >
> >
> > On Tue, Nov 11, 2008 at 3:52 PM, Chris Webb <chris(a)hullomail.com>
> > wrote:
> > Steve,
> >
> > I hope you don't mind me approaching you directly with regard
> > to an issue I have. Please direct me to a more appropriate
> > channel if necessary.
> >
> > Back on the 21/05/03 I raised an issue (HB-92) to do with no
> > support for retrieving a native generated identifier using a
> > custom user type identifier. In a nutshell I had a custom user
> > type that wrapped a long and for all intensive acted like a
> > long but would not work with retrieving the native
> > auto-increment identifier because it wasn't exactly the Long
> > class. In Feb 2005 Gavin provided a solution regarding using a
> > PostInsertIdentifierGenerator but I didn't quite understand
> > how to utilise this. Now in 2008 I am revisiting this problem
> > and the issue seems to still exist with the original config.
> >
> > <class name="VxsContact" table="VXS_CONTACT">
> >
> > <id name="id" column="CONTACT_ID"
> > type="com.voxsurf.pim.contacts.persistence.hibernate.VxsContactIdLongType">
> > <generator class="native"/>
> > </id>
> > .
> > .
> > .
> > </class>
> >
> > The Hibernate code has moved on quite a bit since 2003 but
> > looking at the current GA release (v3.3.1) the problem seems
> > to be in
> > org.hibernate.id.IdentifierGeneratorFactory.get(ResultSet rs,
> > Type type). Despite the 'type' being passed into this method
> > the fact it may be a custom type is ignored and only types
> > that return Long, Integer, Short or String classes are
> > accepted.
> >
> > I have managed to hack the code to hardcode creating my custom
> > type if the relevant type is passed in to this method and this
> > appears to work.
> >
> > // unhappy about this being public ... is there a better
> > way?
> > public static Serializable get(ResultSet rs, Type type)
> > throws SQLException, IdentifierGenerationException {
> > // NOTE: This is a hack to return a specifc custom
> > type identifier.
> > if
> > (type.getReturnedClass().equals(VxsContactIdLong.class)) {
> > return new VxsContactIdLong(rs.getLong( 1 ));
> > }
> >
> > Class clazz = type.getReturnedClass();
> > if ( clazz == Long.class ) {
> > return new Long( rs.getLong( 1 ) );
> > }
> > else if ( clazz == Integer.class ) {
> > return new Integer( rs.getInt( 1 ) );
> > }
> > else if ( clazz == Short.class ) {
> > return new Short( rs.getShort( 1 ) );
> > }
> > else if ( clazz == String.class ) {
> > return rs.getString( 1 );
> > }
> > else {
> > throw new IdentifierGenerationException( "this id
> > generator generates long, integer, short or string" );
> > }
> >
> > }
> >
> > So the question is, could the 'type' passed in be used to
> > create the appropriate identifer type rather than only
> > supporting a fixed set of basic types. Looking at the TRUNK it
> > appears you have been making further changes to this area and
> > maybe this functionality has already been enabled.
> >
> > I have attached relevant classes. Let me know if you need any
> > further information.
> >
> > Look forward to hearing from you.
> >
> > Best regards,
> > Chris
> >
> > --
> > Voicemail that's yours to keep!
> > Sign up @ www.hullomail.com
> >
> > Chris Webb
> > CTO
> > HulloMail Ltd
> > e) chris.webb(a)hullomail.com
> > m) +44 77 8639 2359
15 years, 11 months
Doubts in using Hibernate with createQuery with JPA annotations
by Paulo Ribeiro
Hello,
I'm using JPA with Hibernate 3.2.6 JPA and a party with some queries I
use Hibernate
I wanted to take a createQuery doubts about because I have an object
I'm using JPA Annotation in the two objects ....
One is a Public Private (1-1)
When I try to bring in a select object of my mistake
doing join between these objects .....
-------------------------
try{
Session session = (Session) get.getManager().getDelegate();
List listas = session.createQuery("select pri from Public as pub
join pub.Private as pri where pub.id=4")
.list();
System.out.println("Size listas = "+listas.size());
} catch(Exception e){
System.out.println("Erro ="+e);
}
-- da o erro
Erro testCreateQuery() =org.hibernate.QueryException: could not
resolve property: Private of: br.com.Public [select pri from
br.com.Public as pub join pub.Private as pri where pub.id=4]
------------------------------------
and so when I do not give me error
My question is I have Proquar query with 5 objects (tables) that I
will have to show the scope of each
object. Example: select a.codigo, b.nome, c.saldo, d.saldoanterior
from the object, object, b, c object, object d
How well do ?????? since when do I join between the objects of error ??????????
With the above situation it worked because it is (1-1) and when you
have (1-N) of various objects ....
If anyone can help me would ...
Tks
---------------------
List listas = session.createQuery("select pri from Private as pri
where pri.id=4")
.list();
System.out.println("Size listas = "+listas.size());
-- resultado
Size listas = 1
-----------------------------------
import java.security.PublicKey;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;
@Entity
@Table(name="PUBLIC")
public class Public extends AbstractImsPublicKey {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name = "PUBLICKEY_ID")
private long id;
@Column
private int keySize;
@Column
private Date generationDate;
@Column
private String base64EncodedPublicKey;
private transient PublicKey publicKey;
@OneToOne(mappedBy = "publicKey")
private ImsDigitalCertificateImpl cert;
public Date getGenerationDate() {
return generationDate;
}
public int getHandle() {
// TODO Auto-generated method stub
return 0;
}
public PublicKey getPublicKey() {
return publicKey;
}
public void setGenerationDate(Date date) {
this.generationDate = date;
}
public void setHandle(int handle) {
// TODO Auto-generated method stub
}
public void setPublicKey(PublicKey publicKey) {
this.publicKey = publicKey;
}
public Long getId() {
return id;
}
public String getBase64EncodedPublicKey() {
return base64EncodedPublicKey;
}
public int getKeySize() {
return keySize;
}
public void setBase64EncodedPublicKey(String key) {
this.base64EncodedPublicKey = key;
}
public void setKeySize(int size) {
this.keySize = size;
}
public ImsDigitalCertificateImpl getCert() {
return cert;
}
public void setCert(ImsDigitalCertificateImpl cert) {
this.cert = cert;
}
public void setId(long id) {
this.id = id;
}
}
-----
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
@Entity
@Table(name="PRIVATE")
public class Private extends AbstractProtectedPrivateKey {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name = "PRIVATEKEY_ID")
private long id;
@Column
private String base64EncodedPrivateKey;
@OneToOne
@JoinColumn(name = "PUBLICKEY_ID")
private ImsPublicKeyImpl publicKey;
public String getBase64EncodedPrivateKey() {
return base64EncodedPrivateKey;
}
public void setBase64EncodedPrivateKey(String raw) {
this.base64EncodedPrivateKey = raw;
}
public Long getId() {
return id;
}
public ImsPublicKeyImpl getPublicKey() {
return publicKey;
}
public void setPublicKey(ImsPublicKeyImpl publicKey) {
this.publicKey = publicKey;
}
public void setId(long id) {
this.id = id;
}
}
15 years, 11 months
Search: dropping support for changes through IndexReader
by Sanne Grinovero
Hi, some more steps towards mass indexing:
do you agree I'll drop the capability to use an IndexReader to make
changes to the index?
This implies I'll simplify the backend by removing all methods working
on an IndexReader (they are not needed anymore),
and is required to reuse the IndexWriter as next improvement.
Also we'll need to change the FSMasterDirectoryProvider to use
Lucene's snapshotting feature instead of
the DirectoryProvider lock (is HSEARCH-152).
Another solution would be to replace the lock-holding with a signal
like "please release it to me for a moment"
or even delegate the task to the thread owning the IndexWriter.
BTW this will mean the DirectoryProvider won't be used by anybody.
Sanne
15 years, 11 months
How to tune the Hibernate cache for a big database table
by Mariani, Renato
Having a big table to mapping, I’m thinking to divide it into more different physical table in order to be able to tune better the used cache. What do you think about it ? Is there any other possibility to find out the problem without divide the database table ? I’m thinking to database table portioning and/or Hibernate query result caching.
For instance We may have the following scenario:
a table containing all the bus stop around the world for each bus provider
a Web Services to book a bus trip
If we have just one bus provider mostly used how we can cache just its bus station ?
Thank in advance and best regards Renato.
If you are not the intended recipient of this e-mail message, please notify the sender
and delete all copies immediately. The sender believes this message and any attachments
were sent free of any virus, worm, Trojan horse, and other forms of malicious code.
This message and its attachments could have been infected during transmission. The
recipient opens any attachments at the recipient's own risk, and in so doing, the
recipient accepts full responsibility for such actions and agrees to take protective
and remedial action relating to any malicious code. Travelport is not liable for any
loss or damage arising from this message or its attachments.
15 years, 11 months
RFC: implement criteria API query of collection-of-component and collection-of-value
by David Mansfield
The attached patch, which is NOT ready for inclusion, but works
completely under very light testing, implements the functionality
missing from the criteria API for querying collections that are not
collection-of-entity. (ie. fix the causes of 'collection is not an
association', (i.e first issue on 'Advanced Problems' faq)).
This needs some feedback and review. I have created issue
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3646 to
track the issue, but I've not yet received any feedback.
Implementation notes:
The main area of change is to the CriteriaQueryTranslator class. In
this class, we replace the 'criteriaEntityNames' map of Criteria =>
String with two maps, one mapping Criteria => CriteriaInfoProvider and
one mapping String (name) => CriteriaInfoProvider.
The new class, CriteriaInfoProvider is an interface/abstraction to the
functionality needed by the various entry points into the translator,
such as to retrieve the 'spaces', get the PropertyMapping etc.
There are 3 concrete implementations of CriteriaInfoProvider:
* EntityCriteriaInfoProvider: this is the functionality that was always
present in the translator, ie. use getEntityPersister() etc.
* ComponentCollectionInfoProvider: this is the functionality that
extends the api for collection-of-component. In this class, we have to
provide the collection 'spaces' and the 'collection persister', but we
also have to look in detail at the ComponentType to be able to resolve
property references off of the component.
* ScalarCollectionInfoProvider: this is the functionality the provides
the api for collection-of-value. The main thing here is we use the
SessionFactoryHelper (part of the HQL tree) to get the
CollectionPropertyMapping object for mapping the 'elements','indices'
etc. properties. There's at least one 'I have no idea what to put here'
method in this class.
There is substantial cruft in the patch for debugging, which will not be
part of the final implementation.
There is a crude hack in CriteriaJoinWalker which needs some expert
advice: the existing implementation was looking at some mysterious
'consumesEntityAlias' boolean, but I need to force the code to lookup
the alias from the translator every time, or else it bypasses the alias
for the collection itself, and the SQL aliases are wrong.
There is also a completely separate bugfix wedged in here, which needs
to be extracted to its own issue/patch. The changes to JoinWalker are
necessary and correct: if the last association will not generate any
selectFragment, then the implementation adds an extraneous ", " to the
generated string.
Looking forward to your feedback and working together to get this into
the tree. Need info about test cases to create, documentation etc.
Thanks,
David Mansfield
Cobite, INC.
15 years, 12 months