Problem setting the package name using Hibernate Tools.
by Sri Gowri
Hi,
I am experiencing a problem with the package name declaration during pojo and mapping generation with Hibernate Tools without using Ant.
hibernate.cfg.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate
Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="session1">
<property name="hibernate.dialect">org.hibernate.dialect.DerbyDialect</property>
<property name="hibernate.connection.driver_class">org.apache.derby.jdbc.ClientDriver</property>
<property name="hibernate.connection.url">jdbc:derby://localhost:1527/travel</property>
<property name="hibernate.connection.username">travel</property>
<property name="hibernate.connection.password">travel</property>
</session-factory>
</hibernate-configuration>
hibernate.reveng.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering PUBLIC
"-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd">
<hibernate-reverse-engineering>
<table-filter exclude="false" match-catalog=".*" match-name="FLIGHT" match-schema=".*"/>
<table-filter exclude="false" match-catalog=".*" match-name="PERSON" match-schema=".*"/>
<table-filter exclude="false" match-catalog=".*" match-name="TRIP" match-schema=".*"/>
<table-filter exclude="false" match-catalog=".*" match-name="TRIPTYPE" match-schema=".*"/>
</hibernate-reverse-engineering>
Code that generates pojos and mapping files:
try {
cfg = new JDBCMetaDataConfiguration();
OverrideRepository or = new OverrideRepository();
InputStream xmlInputStream = new FileInputStream(FileUtil.toFile(revengFile));
xmlHelper = new XMLHelper();
entityResolver = XMLHelper.DEFAULT_DTD_RESOLVER;
List errors = new ArrayList();
SAXReader saxReader = xmlHelper.createSAXReader("XML InputStream", errors, entityResolver);
org.dom4j.Document doc = saxReader.read(new InputSource(xmlInputStream));
Configuration c = cfg.configure(confFile);
cfg.setReverseEngineeringStrategy(or.getReverseEngineeringStrategy(new DefaultReverseEngineeringStrategy()));
cfg.readFromJDBC();
} catch (Exception e) {
Exceptions.printStackTrace(e);
}
// Generating POJOs
FileObject pkg;
try {
pkg = SourceGroups.getFolderForPackage(helper.getLocation(), helper.getPackageName());
File outputDir = FileUtil.toFile(pkg);
POJOExporter exporter = new POJOExporter(cfg, outputDir);
exporter.getProperties().setProperty("jdk", new Boolean(helper.getJavaSyntax()).toString());
exporter.getProperties().setProperty("ejb3", new Boolean(helper.getEjbAnnotation()).toString());
exporter.start();
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
// Generate Mappings
try {
pkg = SourceGroups.getFolderForPackage(helper.getLocation(), helper.getPackageName());
File outputDir = FileUtil.toFile(pkg);
HibernateMappingExporter exporter = new HibernateMappingExporter(cfg, outputDir);
exporter.start();
} catch (Exception e) {
Exceptions.printStackTrace(ex);
}
in the code outputDir is
C:\Documents and Settings\gowri\MyDocuments\NetBeansProjects\WebApplication57\src\java\Travel.
But the generated pojo and mapping files don't contain package as Travel .
// default package
// Generated May 27, 2008 12:45:56 AM by Hibernate Tools 3.2.1.GA
import java.util.Date;
/**
* Person generated by hbm2java
*/
public class Person implements java.io.Serializable {
private int personid;
private String name;
private String jobtitle;
private Short frequentflyer;
private Date lastupdated;
public Person() {
}
public Person(int personid) {
this.personid = personid;
}
public Person(int personid, String name, String jobtitle, Short frequentflyer, Date lastupdated) {
this.personid = personid;
this.name = name;
this.jobtitle = jobtitle;
this.frequentflyer = frequentflyer;
this.lastupdated = lastupdated;
}
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated May 27, 2008 12:45:57 AM by Hibernate Tools 3.2.1.GA -->
<hibernate-mapping>
<class name="Person" table="PERSON" schema="TRAVEL">
<id name="personid" type="int">
class name should be Travel.Person.
Wondering why tools is not setting the package right ?
Secondly, even though I have defined the HibernateReverseEngineeringStrategy, why tools is generating pojos and mapping files for all the tables in the db ? (Note:I have listed only selected tables in the hibernate.reveng.xml).
16 years, 6 months
Hibernate Search: approval for changes, "commit conventions"?
by Sanne Grinovero
Hi Emmanuel,
(looking around the sources again) I am making several changes,
but I am feeling the urgency to ask your opinion about
"commit conventions"
1)is it ok in case of a "code revision" to have a commit of >100 files
for very trivial changes ( wrong formatting, spelling typos in comments,
unused import removals);
do I have to warn you before commits of this type?
should I leave them all as-is?
2)There are some "//TODO serialization" on classes that could implement
Serializable trivially, is it ok if I just add them ?
(I'll don't do it for cases I have doubts)
3)//TODO set a serial number
May I auto-generate a serialVersionUID for classes were missing,
or do you have some special policy about them I should be aware of?
4)final fields:
some constructor-initialized fields may need the final keyword, especially
wen producing thread-safe transfer objects; I've added several already,
I'm wondering now if it's ok to have this changes committed together
with 1) or if you would have preferred separated commits.
Also using "final" really helps me in better understanding the overall code.
5)static logger:
some classes (e.g. org.hibernate.search.engine.QueryLoader) "forget"
to declare the Logger as static, if this is intentional I would like to know
more about it. May I fix them all if I find more?
Is it because of hot-redeploy? In this case I would need to remove
some statics;-)
6)java.util.collections
there's a nice
List EMPTY_LIST = new ArrayList( 0 );
in QueryLoader; I would like to replace it with java.util.Collections.EMPTY_LIST
but this has another effect: UnsupportedOperationException if someone
tries to add
elements. I think this is a good thing, but I could be wrong.
Also currently someone could reread data in other queries if adding elements to
the ArrayList.
This exists only since java5, so it's not a good trick for core.
7) the org.hibernate.search.Version class:
what's the idea for the new Date() ? to append the
execution time to version number?
May I move the getLogger in the static {} code block and release the instance?
==
All above questions are about code I've already changed, just need your
opinion before commit.
Now for suggested improvements:
A)defensive copy on public API (FindBugs):
FindBugs is complaining about
"May expose internal representation by incorporating reference to
mutable object"
in serveral places.
I suppose we can trust our own code, but for example in
FullTextQuery setProjection(String... fields)
it would be wise to make an own private copy of the data.
Too much paranoia? Also it would have some performance cost.
B) there's a STATIC field in SharedReaderProvider:
"static Field subReadersField"
it is looking quite suspect, is that really meant to be static?
Also the ReaderData class contained in SharedReaderProvider
isn't looking as threadsafe; I could be wrong I only read
this class once.
I volunteer to examinate it better, also because of HSEARCH-194.
C)Workspace contains many maps to needed objects,
all having the same key "DirectoryProvider"; also locks are
mantained in an array; Woudn't it be easier to have a single map,
returning a container object with all needed stuff;
This object could be passed to all other methods instead of the
dir.Provider and avoid many more gets on the maps.
also some locking code could go "local" in this container
class, I've some difficulty in tracking the lock sequences.
D)There's a TODO somewere about making a "readonly
IndexReader"; I guess to return to users for safety
(there is a comment in the docs:
"This indexReader must not be used for modification operations
(especially delete)")
I have implemented such an IndexReader, but for visibility problems
it needs to have package "org.apache.lucene.index" ;
what do you think? Should I kindly ask to lucene developers
to add it to their package?
It's a very simple wrapper around another reader, throwing "unsupported"
on methods to be avoided.
Sanne
16 years, 7 months
Somasundram Balakrushnan is out of the office.
by somasundram_balakrushnan@keybank.com
I will be out of the office starting 05/27/2008 and will not return until
05/30/2008.
I will respond to your message when I return.
*******************************************************************************
This communication may contain privileged and/or confidential information. It
is intended solely for the use of the addressee. If you are not the intended
recipient, you are strictly prohibited from disclosing, copying, distributing
or using any of this information. If you received this communication in error,
please contact the sender immediately and destroy the material in its entirety,
whether electronic or hard copy. This communication may contain nonpublic personal
information about consumers subject to the restrictions of the
Gramm-Leach-Bliley Act. You may not directly or indirectly reuse or redisclose
such information for any purpose other than to provide the services for which
you are receiving the information.
127 Public Square, Cleveland, OH 44114
*******************************************************************************
If you prefer not to receive future e-mail offers for products or services from
Key send an e-mail to DNERequests(a)key.com with 'No Promotional E-mails' in the
SUBJECT line.
16 years, 7 months
Re: CGLIB 2.2 released
by Steve Ebersole
We had 2 folks try to contact y'all in regards to this, but they never
got any responses.
On May 26, 2008, at 11:19 AM, Chris Nokleberg wrote:
> [not sure if non-members can post to hibernate-dev, if this doesn't
> make it to the list can someone please forward it?]
>
> Sorry for the long delay, Google sucked my time away and I'm not sure
> what happened to Juozas.
>
> Version 2.2 uses ASM 3.1 and fixes a recently discovered thread
> safety bug.
>
> Steve wrote:
>> Our (default) dependency on CGLIB is starting to cause problems due
>> to
>> other libraries using newer versions of ASM (3.x) then the released
>> versions of CGLIB use (2.x). We have now been waiting about a year
>> for a new CGLIB release to use these newer ASM APIs. With 3.3 being
>> eminent, we need to rectify this situation.
>
> FWIW, no one told me you were waiting for a CGLIB release--that
> probably would have been a good idea. Also, the "nodep" version which
> embeds ASM was created specifically to avoid ASM dependency issues.
>
> Chris
-----------------------------
Steve Ebersole
Project Lead
http://hibernate.org
steve(a)hibernate.org
16 years, 7 months
CGLIB proxy policy
by Shahiduzzaman
In the CGLIBLazyInitializer class callbacks are created for the proxy
class. Two callback types are registered - InvocationHandler.class,
NoOp.class. And the callback filter is setup in the following way -
private static final CallbackFilter FINALIZE_FILTER = new CallbackFilter() {
public int accept(Method method) {
if ( method.getParameterTypes().length == 0 &&
method.getName().equals("finalize") ){
return 1;
}
else {
return 0;
}
}
};
This is not clear to me. Why the NoOp type callback is needed and its
selection from the callback filter? If anyone knows please give some
hint (or explanation).
Thanks.
Shahid
N.B. - First I post this to hibernate forum, later I realize that its
a more development related question, so re-posting here.
16 years, 7 months
CGLIB
by Steve Ebersole
Our (default) dependency on CGLIB is starting to cause problems due to
other libraries using newer versions of ASM (3.x) then the released
versions of CGLIB use (2.x). We have now been waiting about a year
for a new CGLIB release to use these newer ASM APIs. With 3.3 being
eminent, we need to rectify this situation.
First, I am going to make javassist the default bytecode provider
starting with Hibernate 3.3 (http://opensource.atlassian.com/projects/hibernate/browse/HHH-2506
).
Next, we need to decide what to do with CGLIB moving forward. This
seems to be a dead project at this point. From my recollection, the
source control for CGLIB does in fact have support for ASM 3.x; so one
option would be to do a build of it from HEAD. However, none of us
are really bytecode gurus, so thats probably not the best option. The
only other option I see is to simply deprecate the integration for
CGLIB and recommend against its use. Any other options we should
explore here?
-----------------------------
Steve Ebersole
Project Lead
http://hibernate.org
steve(a)hibernate.org
16 years, 7 months
No successful builds since move to Maven
by Sanne Grinovero
Most esteemed developers,
I was developing some patches for Hibernate Search but as I work on it on my own
I don't have much time for it; currently some problems about the move to Maven
have completely killed my productivity.
I have found some reference on your website;
The maven guide looks good: http://www.hibernate.org/422.html
but l would appreciate some more information for the eclipse users.
(are you all IDEA users?)
Specifically I have difficulty to understand how to set the correct JDK:
A) cache-jbosscache2 requires JDK5 (for many reasons)
B) org.hibernate.test.ops.MergeTest requires JDK5, as it is using
autoboxing since commit 14610.
C) core is needing jdk1.4, but if I use JDK5 to fix A&B it doesn't
compile because
BlobImpl, ResultSetWrapper, SerializableBlob should implement new
methods that were added in the latest interface versions.
So I didn't understand how other developers are having their project compile;
should I try setting a "mixed JDK" environment? Looks ugly.
Is it possible these problems are related to some maven setting I got wrong?
Currently I disabled jbosscache2, changed the source code of MergeTest
and switched to JDK1.4,
but would like to hear you opinion about it.
Also I actually need jbosscache2 :-(
thanks in advance,
Sanne
16 years, 7 months
SLF4J 1.4.2
by Emmanuel Bernard
Any reason why we target SLF4J 1.4.2 and not 1.5?
16 years, 7 months
Sync maven jboss repo with central repo?
by Tomislav Stojcevich
The jboss maven repo is not currently being sync'd to the central repo
for the org/hibernate packages.
I need the latest entitytManager which is no in central but is in the
jboss repo.
I can't just add the jboss repository in my pom because our
'production' builds are done on a special build server that is behind
a firewall and is only allowed access to the maven central repo for
security reasons. Big Brother is very paranoid. Besides, adding
another repo slows down developer builds since that extra repo has to
be checked for artifacts in addition to central.
Instructions on how to request the sync can be found here:
http://maven.apache.org/guides/mini/guide-central-repository-upload.html
16 years, 7 months