Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to pull data using Spring frame work, Hibernate, and JPA from MS Sql Server 2000  RSS feed

nav katoch
Ranch Hand
Posts: 246
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Team,

Anybody has ever tried to pull data using spring, hibernate, jpa from MS Sql Server 2000 but It's working fine with Oracle.

Please let me know, then I will post the exact stuff on the forum.

Thanks and regards,

Naveen Katoch
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is indeed being done on many enterprise servers. You're not blazing any new ground here, I assure you.

What is the issue you are running into?

-Cameron McKenzie
nav katoch
Ranch Hand
Posts: 246
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks so much for your quick response. I appreciate it. I will post my stuff with some issues.

Thanks again,

nav katoch
Ranch Hand
Posts: 246
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Below is the class file:-TbEngagementVDAO

package com.cpwr.stb.persistence.cp.dao;
// default package

import com.cpwr.stb.persistence.cp.entity.TbEngagementV;
import com.cpwr.stb.persistence.cp.entity.TbEngagementVId;
import com.cpwr.stb.utility.MessageFactory;

import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceException;
import javax.persistence.Query;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.jpa.JpaCallback;

* A data access object (DAO) providing persistence and search support for
* TbEngagementV entities. Transaction control of the save(), update() and delete()
* operations can directly support Spring container-managed transactions or they
* can be augmented to handle user-managed Spring transactions. Each of these
* methods provides additional information for how to configure it for the
* desired type of transaction control.
* @see .TbEngagementV
* @author MyEclipse Persistence Tools

public class TbEngagementVDAO extends JpaDaoSupport implements ITbEngagementVDAO {
// property constants
public static final String NAME = "name";
public static final String BILLING_MANAGER_ID = "billingManagerId";
public static final String ENGAGEMENT_STATUS_DESC = "engagementStatusDesc";
public static final String BILLING_OFFICE_ID = "billingOfficeId";
public static final String BILLING_CURRENCY = "billingCurrency";
public static final String PAYMENT_TERMS = "paymentTerms";
public static final String UDF_CODE_ID = "udfCodeId";
public static final String UDF_CODE_TITLE = "udfCodeTitle";
public static final String UDF_CODE_VALUE = "udfCodeValue";
public static final String UDF_TEXT_TITLE = "udfTextTitle";
public static final String UDF_TEXT_VALUE = "udfTextValue";

* New DAO methods Added by Nitya Ganesh

public List<TbEngagementV> findLikeName(final String customerId,
final String token) {"findLikeName: Finding TbEngagementV records with customerId: "
+ customerId + ", name: " + token);
MessageFactory messageFactory = new MessageFactory();
final int maxRows = Integer.parseInt((String)messageFactory.getMessage("typeahead.max_rows"));

try {
String tmpQueryString = "select model from TbEngagementV model where lower( like lower(:value)";
if (customerId != null){
tmpQueryString +=" and model.CUSTOMER_ID = :customerId";
tmpQueryString += " order by CUSTOMER_ID, ENGAGEMENT_ID";
final String queryString = tmpQueryString;
return getJpaTemplate().executeFind(new JpaCallback() {
// TODO - check if this part needs to be changed
public Object doInJpa(EntityManager em)
throws PersistenceException {
Query query = em.createQuery(queryString);
query.setParameter("value", token);
if (customerId != null) query.setParameter("customerId", customerId);
query.setMaxResults(maxRows + 1);
return query.getResultList();
} catch (RuntimeException re) {
logger.error("find by name failed", re);
throw re;


<persistence-unit name="stabMSSQLPU" transaction-type="RESOURCE_LOCAL">

<property name="hibernate.connection.driver_class" value=""/>
<property name="hibernate.connection.url" value="jdbc:sqlserver://dtw-chgptsql1:1433"/>
<property name="hibernate.connection.username" value="stabtest"/>
<property name="hibernate.connection.password" value="test"/>
<property name="hibernate.show_sql" value="true"/>

<bean id="engagementService"
lazy-init="default" autowire="no" dependency-check="default">
<!-- property name="engagementDAO"
ref="EngagementDAO" /> -->
<property name="seEmpGlAccessCtrlVService" ref="seEmpGlAccessCtrlVService"></property>
<property name="tbEngagementVDAO"
ref="TbEngagementVDAO" />

It's not returning any data here. Do I need any settings anywhere else? Your help and suggestion will highly be appreciated.

query.setMaxResults(maxRows + 1);
return query.getResultList();

Cameron, I will eagerly wait for your fruitful comments and feedback.

Thank you very much

naveen katoch
Edison Gualberto
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have an article regarding spring transactions on JPA
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!