Hi there,
Hibernate does not support Teradata database and I did manually written, config,mapping file and POJO file and when I try to
test, I am getting following error
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
%%%% Error Creating HibernateSessionFactory %%%%
org.hibernate.MappingException: Could not determine type for: java.lang.string, for columns: [org.hibernate.mapping.Column(METRO_NAME)]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:266)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:253)
at org.hibernate.mapping.Property.isValid(Property.java:185)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:395)
at org.hibernate.mapping.RootClass.validate(RootClass.java:192)
at org.hibernate.cfg.Configuration.validate(Configuration.java:984)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1169)
at InitSessionFactory.initSessionFactory(InitSessionFactory.java:106)
at InitSessionFactory.getInstance(InitSessionFactory.java:54)
at TestClient.main(TestClient.java:31)
Exception in
thread "main" org.hibernate.HibernateException: Could not initialize the Hibernate configuration
at InitSessionFactory.initSessionFactory(InitSessionFactory.java:111)
at InitSessionFactory.getInstance(InitSessionFactory.java:54)
at TestClient.main(TestClient.java:31)
Picked up _JAVA_OPTIONS: -Dawt.toolkit=mercury.awt.awtSW -Xrunmicsupp -Xbootclasspath/a:C:\PROGRA~1\COMMON~1\MERCUR~1\SHARED~1\JAVAAD~1\classes;C:\PROGRA~1\COMMON~1\MERCUR~1\SHARED~1\JAVAAD~1\classes\mic.jar
here is my code
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.bytecode.use_reflection_optimizer">false</property>
<property name="hibernate.connection.driver_class">teradata.jdbc.driver.TeradataDriver</property>
<property name="hibernate.connection.password">monday</property>
<property name="hibernate.connection.url">uri =
jdbc:teradata://slgo1093/</property>
<property name="hibernate.connection.username">donb999</property>
<property name="hibernate.default_schema">LST</property>
<property name="hibernate.dialect">org.hibernate.dialect.GenericDialect</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- Enable Hibernate's automatic session context management -->
<!-- <property name="current_session_context_class">thread</property> -->
<property name ="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory </property>
<property name="jta.UserTransaction">
java:comp/UserTransaction</property>
<!-- Disable the second-level cache -->
<!-- <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property> -->
<property name="cache.provider_class">org.hibernate.cache.OSCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">create</property>
<mapping resource="NqsMtro.hbm.xml" />
</session-factory>
</hibernate-configuration>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Jun 2, 2006 9:47:52 AM by Hibernate Tools 3.1.0.beta5 -->
<hibernate-mapping>
<class name="NqsMtro" table="LISDVP30.NQS_MTRO">
<meta attribute="implement-equals">true</meta>
<cache usage="read-only"/>
<id name="metroName" type="string">
<column name="METRO_NAME" precision="9" scale="0" />
<generator class="assigned" />
</id>
<property name="metroName" type="java.lang.string">
<column name="METRO_NAME" precision="9" scale="0" />
</property>
<property name="regName" type="java.lang.string">
<column name="REG_NAME" precision="9" scale="0" />
</property>
</class>
</hibernate-mapping>
Test client
import java.util.Iterator;
import java.util.List;
import org.apache.log4j.Logger;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.transaction.JTATransaction;
import org.hibernate.context.*;
import sun.rmi.runtime.NewThreadAction;
import java.util.Iterator;
//import com.vladium.utils.timing.ITimer;
//import com.vladium.utils.timing.TimerFactory;
public class TestClient {
/**
* @param args
*/
public static void main(
String[] args) {
// TODO Auto-generated method stub
// Create an ITimer using the Factory class:
// final ITimer timer = TimerFactory.newTimer ();
Session newSession = InitSessionFactory.getInstance().getCurrentSession();
NqsMtro obj = new NqsMtro();
//obj.setMetroName("xcov178");
//
//obj.setRegName("Nag");
try{
//UserTransaction newTransaction = (UserTransaction) new InitialContext().lookup("java:comp/UserTransaction");
Transaction newTransaction = newSession.beginTransaction();
//timer.start();
//newSession.save(obj);
//List messages = newSession.load(LstAct.class, new Long(1));
Query query = newSession.createQuery("from NqsMtro");
java.util.List result = query.list();
//java.util.List messages2 = newSession.createSQLQuery("SELECT * from LST_ACT");
//System.out.println("Messages"+messages.size());
Iterator iter = result.iterator();
while(iter!=null && iter.hasNext()){
NqsMtro message = (NqsMtro)iter.next();
System.out.println("LSTACT Table and column :"+message.getMetroName());
System.out.println("LSTACT Table and column :"+message.getRegName());
}
newSession.getTransaction().commit();
//timer.stop();
//System.out.println("Time Duration "+timer.getDuration()+"ms");
newSession.close();
}
catch(RuntimeException ex){
newSession.getTransaction().rollback();
ex.printStackTrace();
}
}
}