OSGI Equinox with Hibernate JPA Setting up - java

I am setting up a simple example to persist one Person entity using Hibenate in an OSGI Equinox using eclipse. I read the official documentation in Hibernate web site but the examples use another frameworks and I dont know how many bundles I need and how to set up them.

After a few days trying to use hibernate in an Equinox Osgi, I get it. I created a thread in the Hibernate Forum so you can go there:
https://forum.hibernate.org/viewtopic.php?f=1&t=1029974&p=2473673#p2473673
Basically you need to do step by step, setting up every bundle that you need, and also updated to the Hibernate 4.3.0 version and take care with the order of your bundles in run time!!

Related

Hibernate integration on a Spring web application

I have been following this tutorial on the Springsource website in order to have basic knowledge of Spring. Everything went good.
Now, I would like to integrate Hibernate to this little application I wrote following this tutorial. I found documentation on different websites (including hibernate's website) but I still have a few questions before starting.
I read some stuff about JPA and I can use it as an abstraction layer on top of hibernate but I don't really understand what for.
In addition, I read somewhere that there is two ways to use hibernate, the first one is annotations and the second one is using javax.persistance, I am right?
Is there some recent documentation about how to use hibernate in an existing spring web application, as well as the different ways to implement it?
JPA is a specification, hibernate can be considered as a implementation of the JPA spec.
You can use either annotation for mapping file with hibernate.
The following tutorials are better:
Hibernate Tutorial Vaannila
Hibernate Tutorial Mkyong
JPA is a standard, Hibernate is an implementation, but has other/additional functionality.
The Spring Reference manual's section on ORM integration covers Hibernate. There are also scores of tutorials and demos, like here, but there are a bunch of other ones, and more recent ones.

Configure Glassfish 3 with Hibernate 3.6

I am trying to configure hibernate 3.6.7 with glassfish 3.1.1.
If I just install the module from update-tool in glassfish I get hibernate 3.5...
I want to use hibernate search 3.4.1 Final.
I want to build a website and I will have lots of items into database and I want it work ok (use lucene search integrated in hibernate). - I want to use lucene spellchecker later
Do you suggest me to switch to jboss AS 7? I am willing to create a java ee application (ejb, standalone web tier) if so... do I have to create more xml's, configuration stuff for jboss as 7? or just add my datasource and I'm done...???
Or should I make my lucene code and use it with eclipselink?
What do you think it's best?
Regards
I use Eclipse and glassfish 3.1 with Hibernate 3.6.7. and hibernate search. Everything works fine. You don't need tons of xml, I use JPA so I have persistence.xml. I set my database access in glassfish, put the jta datasource into the persistence.xml and some hibernate search related config, that's all.
I tried jboss too, but I think glassfish is easier to use. I don't know what's the best, pick one and try it :)
With the help of #hcpeter I managed to configure...
Here is how is done:
Copy all jar files (only jar files, no folders.. take the jars out of the folders) in glassfish3/glassfish/lib/

Hibernate Search Configuration Help

I am trying to configure hibernate search for my application by reading several web tutorials, the majority uses annotation but I uses xml mapping, also, many tutorial are saying to use spring and maven while I don't uses these.
Can someone help and provide some starting point for configuring hibernate search, many web tutorial are not working for me
The application is a gwt application using gilead with hibernate on the back end
As pointed out in the previous answer, Hibernate Search does not have a xml configuration. You can configure Hibernate via xml, but not Search. Since Hibernate Search 3.3 there is an alternative, however, which is the programmatic configuration api - http://docs.jboss.org/hibernate/stable/search/reference/en-US/html_single/#hsearch-mapping-programmaticapi
There is an object called SearchMapping. Once instantiated it offers an fluent API to configure Search the same way you would do with annotations. Add the configured SearchMapping instance to your Hibernate Configuration instance using the key *hibernate.search.model_mapping* and Search will automatically bootstrap together with Hibernate Core. There is not much to it. You don't need Spring.
Once Search is running you probably want to write a few lines of code to index your existing database. There is code for that in the online manual.
Last, but not least you need some searches. Have a look how to create a FulltextQuery. Your system probably gets some sort of search input in what for so ever. Your task is to transform the search input from the "frontend" into a Lucene query which you can then pass to Search in order to execute the search and return managed objects.
Last, but not least - maven is a completely different thing. Now we are talking build systems. Using maven you can get automatically download the artifacts from the JBoss Maven repository. However, there are also dist bundles on SourceForge is this is more what you are after. Check http://www.hibernate.org/subprojects/search/download for Search download information.
Hope this helps.
http://docs.jboss.org/hibernate/search/3.3/reference/en-US/html_single/#d0e43
Hibernate Search, however, has itself its own set of annotations (#Indexed, #DocumentId, #Field,...) for which there exists so far no alternative configuration.
I also remember seeing something like this in "Hibernate Search in Action", where the author said that there's not much demand for non-annotation configuration (I don't have my copy now, so, I may be wrong). I guess that there is still not enough demand.
Note that Hibernate itself can be configured via XML, and I assume that you can mix both (XML for Hibernate mappings, annotations for Hibernate Search mappings).

OSGI - Hibernate + JBoss Seam

I am running a JBoss Seam web application with Hibernate as the persistence provider. I am considering migrating to OSGI to simplify deployment and updates.
I don't have any experience yet with OSGI, so I don't know if this can be done and what the limitations are.
For instance, if I change entity classes and I want Hibernate to drop some tables and create some new ones, will that be possible? Does hibernate need to have hooks into OSGI so it knows to drop table a and create table b?
Walter
I'm not sure I fully grasp your question. If you choose to use OSGi to modularize your application, that choice has no impact on the behavior of Hibernate. You can, of course, make calls into Hibernate's SchemaExport or SchemaUpdate APIs when you activate bundles to manage your schema, but Hibernate won't drive that process for you. You'll have to do it yourself.

eclipse default jpa implementation library where to download?

In eclipse, the "default implementation library" what jars files do I need to include if I do not want to use server runtime?
I'm refering to this tutorial http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse.jpt.doc.user/task_create_new_project.htm
Follow Using TopLink JPA with Dali to get started with the Toplink Essentials (JPA reference implementation). To get the mentioned jars (toplink-essentials.jar and toplink-essentials-agent.jar), download them from there or, if you use Maven, from the Java.Net Maven Repository.
PS: Please note that after 2.0-b36, the toplink-essentials-agent.jar file is no longer needed as the agent facility is now integrated into toplink-essentials.jar. So you can do like below.
$ java -javaagent:toplink-essentials.jar client.Client
Depends on what implementation you want to use. There are currently three most popular implementations: Hibernate, TopLink and EclipseLink.
I know about hibernate that it's README file explains what jars are mandatory for what functions. If you use JPA you must have some sort of EntityManager (hibernate can be used without EntityManager too), so you need all the dependencies of it.
To download hibernate JPA implementation use this link (look for hibernate-entitymanager). You need hibernate core, annotations and entity manager for JPA. If you use all the jars in those three packages you should be ok. But I strongly suggest you to read the README files.

Categories

Resources