Multiple databases using hibernate annotations

Database and Table Structure: DATABASE : DATABASEONE Table: EMPIDNAME EMPID INT(4) EMPNAME VARCHAR(15) DATABASE : DATABASETWO Table : EMPIDSALARY EMPID INT (4) EMPSALARY INT(4) Project Structure: Step 1: Hibernate configuration files for both databases: first database (DATABASEONE) hibernate configuration file (hibernate1.cfg.xml): <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <!– Database connection configurations –> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>

156 total views, no views today

» Read more

Multiple databases using hibernate example

Database and Table Structure: DATABASE : DATABASEONE Table: EMPIDNAME EMPID INT(4) EMPNAME VARCHAR(15) DATABASE : DATABASETWO Table : EMPIDSALARY EMPID INT (4) EMPSALARY INT(4) Project Structure: Step 1: Hibernate configuration files for both databases: first database (DATABASEONE) hibernate configuration file (hibernate1.cfg.xml): <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <!– Database connection configurations –> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>

70 total views, no views today

» Read more

Hibernate Join Annotation Example

Hibernate Join Annotation example: Dowload the Required JAR files: Hibernate Jar Files Table Structure: EMPNAME TABLE (empid int, empname varchar); EMPSALARY TABLE (empid int, empsalary int); and table holds the below sample values like below, EMPNAME:                                                

63 total views, no views today

» Read more

Hibernate Select Annotation Example

Hibernate select annotation example: Dowload the Required JAR files: Hibernate Jar Files Table Structure: EMPNAME TABLE (empid int, empname varchar); EMPSALARY TABLE (empid int, empsalary int); and table holds the below sample values like below, EMPNAME:                                                

107 total views, no views today

» Read more

Hibernate select null value

Hibernate select Null Value: @OneToOne @JoinColumn(name=”documentSearchCriteriaId”, referencedColumnName=”documentSysId”, nullable=true) (or) @OneToOne(fetch=FetchType.LAZY) (or) @OneToOne(fetch=FetchType.EAGER) but if null value encountered then it will simply exit without throwing error, it will not continue executing with next row values. If you have any other solution kindly post in the comment area. Thanks. 74 total views, no views today

74 total views, no views today

» Read more

[Solved] exception in thread main org.hibernate.hql.ast.querysyntaxexception is not mapped

Exception in thread main org.hibernate.hql.ast.querysyntaxexception is not mapped: List myList = s.createQuery(“FROM hibernate“).list(); in the above hibernate is the table name. We have to change that table name to class name that is mapped with above hibernate table name like below, List myList = s.createQuery(“FROM Hibernate“).list(); Hibernate is the Class name and it is case sensitive.   Recommended Books:    

177 total views, 1 views today

» Read more

[solved] exception in thread main java.lang.noclassdeffounderror wrong name

Exception in thread main java.lang.noclassdeffounderror wrong name: This error may occur due to the below line in your hibernate project, List employees = s.createQuery(“FROM employee”).list(); we must use “From Employee” while selecting from our db using hibernate. Eventhough we have created our table as EMPLOYEE also we must specify there as “From Employee” only. After changing this to List employees

43 total views, no views today

» Read more
1 2