I gave recently a talk at Voxxed Istanbul 2015 and I’d like to share here the story of this talk.
The talk was about adding a real search engine for your legacy application. Here “legacy” means an application which is still using SQL statements to execute search requests.
Our current CRM application can visualize our customers. Each person is represented as a Person bean and have some properties like name, dateOfBirth, children, country, city and some metrics related to the number of clicks each person did on the car or food buttons on our mobile application (center of interests that is).
I gave recently a talk at Devoxx France 2015 with Colin Surprenant and I’d like to share here some of the examples we used for the talk.
The talk was about “what my data look like?”.
We said that our manager was asking us to answer some questions:
who are our customers? how do they use our services? what do they think about us on Twitter? Our CRM database So we have a PostgreSQL database containing our data.
I was trying to use Hibernate 4.3.8.Final with Log4J2 and I spent some hours to find why Hibernate was not using Log4J2 though it was declared in my pom.xml file.
Actually, I hit issue JBLOGGING-107.
The workaround is simply to add a more recent jboss-logging dependency than the one shipped by default with Hibernate 4.3.8.Final.
<dependency> <groupId>org.jboss.logging</groupId> <artifactId>jboss-logging</artifactId> <version>3.2.1.Final</version> </dependency>
Elasticsearch, un projet mature en quelques mois… A suivre de très près !
En cherchant un bout de code pour rendre la couche Hibernate Search facilement distribuable sur un cluster de machines JBoss, je suis tombé sur le projet Elasticsearch.
Au début, un peu interloqué… Puis, je me lance…
Je télécharge le projet. Je dézippe.
Je lance…
Miracle. En quelques secondes, je dispose d’un outil dans un Cloud, simple, me permettant d’indexer n’importe quel type de document, de le récupérer et de faire une recherche (au sens google du terme) sur n’importe quel champ… Et cela, quelque soit la technologie employée (Java, C#, .
Lorsqu’on utilise Hibernate pour déléguer la gestion de la persistence, se pose alors le classique problème de l’exception LazyInitialisationException.
En effet, dans une modélisation assez classique, imaginons le cas suivant :
Couche Modèle (ou DAO) Classe POJO contenant un attribut x et une collection cols @Entity @Inheritance(strategy=InheritanceType.SINGLE_TABLE) public class Dossier { @Id @GeneratedValue private Long id; private String x; @OneToMany(cascade=CascadeType.ALL) private Collections cols; // Getter et setters } Classe DAO Voir le blog pour l’utilisation des generics de Java5 afin d’éviter d’avoir à coder toujours les mêmes méthodes CRUD.