Skip to content
Advertisement

Tag: hibernate

How to join 3 table using hibernate criteria?

I have three tables. parent parent_child_mapping child I want to join the 3 tables & filter by child name using ‘CriteriaBuilder’ & ‘Predicate’. How can i implement the below sql query using ‘CriteriaBuilder’ & ‘Predicate’. Parent entity Parent child mapping entity Child entity Answer You just create a root for every entity and add the condition to the where clause.

Difference between connecting to a database using DriverManager and SpringBoot(Hibernate)

There are 2 ways to connect to a database when developing Java apps. Using DriverManager Connection conn = DriverManager.getConnection(url, name, password); // execute the query. Using application property file in SpringBoot spring.jpa.hibernate.ddl-auto=none spring.datasource.url=jdbc:mysql://localhost:5432/db_name spring.datasource.username=user spring.datasource.password=password Now you can use @Entity annotation on your class to put data into database. My question is how are these 2 ways different. If not

how to resolve Joda date/time type `org.joda.time.DateTime` not supported by default

I have an existing web-app and unfortunately the ‘time’ fields in the DB are not converted to zulu time. Instead we are using org.joda.time.DateTime as our datetime and timezone encapsulator. I am in the process of updating from hibernate 4.3.7.Final to 5.3.20.Final Also, we are letting hibernate manage the translation of these DateTime objects to/from the db using Running this

Hibernate – Error accessing stax stream – with hibernate.properties

I’m getting this error : INFO: HHH000205: Loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=oracle.jdbc.driver.OracleDriver, hibernate.dialect=org.hibernate.dialect.Oracle8iDialect, hibernate.connection.password=****, hibernate.connection.username=myUserName, hibernate.connection.url=jdbc:oracle:thin:@//myHost:1521/mySID, hibernate.bytecode.use_reflection_optimizer=false, show_sql=true} org.hibernate.HibernateException: Error accessing stax stream at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:107) at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:65) at org.hibernate.boot.cfgxml.internal.ConfigLoader.loadConfigXmlResource(ConfigLoader.java:57) at org.hibernate.boot.registry.StandardServiceRegistryBuilder.configure(StandardServiceRegistryBuilder.java:165) at org.hibernate.cfg.Configuration.configure(Configuration.java:258) at gradletests.HibernateUtils.getSessionFactory(HibernateUtils.java:15) at gradletests.MainTest.main(MainTest.java:14) Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1] Message: Content is not allowed in prolog. at java.xml/com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:652) at java.xml/com.sun.xml.internal.stream.XMLEventReaderImpl.peek(XMLEventReaderImpl.java:277) at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:103) … 6 more

In which direction Hibernate orm-mapping works

I have a rather simple (probably) question, but somehow struggling to find an answer. How does hibernate map nested entities to java objects? Does it starts its mapping from high-level entities and stops on encountering null-values in ResultSet, or it starts from the lowest-level entities and check all of the hierarchy? The first path seems to be more natural, but

Advertisement