So I am trying to connect to an Oracle DB, using spring and hibernate. Everything seems to work other then I can't tell I am getting a connection. In the DAOImpl class I have the following code:
Session session = this.sessionFactory.openSession();
System.out.println("connection: " + session.isConnected());
System.out.println("is open: " +session.isOpen() );
Query q = session.createQuery("from " + Concept.class.getName());
System.out.println(q.getQueryString());
List<Concept> list = q.list();
The both isConnected and isOpen returns true. Yet the list is empty.
In the spring.xml file I went ahead and commented out the username and password, yet isConnected and isOpen still returns true.
So it seems that I am getting some kind of false positive on the connection. How can I check the connection, how can I know that I am connected to the right database? The database is password protected so the connection should fail.
This line:
System.out.println(q.getQueryString());
Prints:
from com.mypackage.Concept
Here is The annotated Concept:
@Entity
@Table(appliesTo = "mySchema.CONCEPT") //I've tried with and without the schema
public class Concept {
@Column( name="ID")
private long id;
@Column( name="CODE")
private String code;
@Column(name="description")
private String description;
The configuration:
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<property name="url" value="jdbc:oracle:thin:@xx1.foo.com:1521:xx" />
<property name="username" value="user" />
<property name="password" value="pass" />
</bean>
<bean id="hibernate3AnnotatedSessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="annotatedClasses">
<list>
<value>mypackage.model.Concept</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
<prop key="hibernate.current_session_context_class">thread</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
mypackage.model.Conceptnotcom.mypackage.Concept@Entitydoesn't appear to have an@Id. Could be causing prior errors. Please post the fullConceptclass.