-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 16 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Getting error while selecting data fromtable.
PostPosted: Thu Feb 25, 2010 9:12 am 
Newbie

Joined: Thu Feb 25, 2010 9:05 am
Posts: 9
Session session = HibernateUtil.getSessionFactory().openSession();
CnxContact contact = (CnxContact)session.get(CnxContact.class, new Integer(6));

While i am executing above two line it's returning error like:
java.lang.StringIndexOutOfBoundsException: String index out of range: 0

I have used annotation.

If is there anybody having idea about it then please help me. I am new in hibernate.


Top
 Profile  
 
 Post subject: Re: Getting error while selecting data fromtable.
PostPosted: Thu Feb 25, 2010 9:18 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Please report the full stacktrace of your StringIndexOutOfBoundsException
and provide informations about how you define the mapping of class CnxContact.class


Top
 Profile  
 
 Post subject: Re: Getting error while selecting data fromtable.
PostPosted: Thu Feb 25, 2010 9:41 am 
Newbie

Joined: Thu Feb 25, 2010 9:05 am
Posts: 9
*****************
CnxContact.java
*****************
package persistent.core;

// Generated Feb 25, 2010 6:21:46 PM by Hibernate Tools 3.2.2.GA

import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
* CnxContact generated by hbm2java
*/
@Entity
@Table(name = "cnx_contact", catalog = "uhc_staging_2")
public class CnxContact implements java.io.Serializable {

private Integer contactId;
private Account account;
private String contactGuid;
private long orgid;
private Date dateOwnerModified;
private Integer homeAddressUid;
private Integer altAddressUid;
private Integer busAddressUid;
private Integer mailingAddressUid;
private String leadId;
private String customerId;
private boolean deleted;
private Date dateEntered;
private Date dateModified;
private Long modifiedUserId;
private Long createdBy;
private String firstName;
private Character middleInitial;
private String lastName;
private String suffix;
private String title;
private Date birthdate;
private String ssn;
private Boolean doNotCall;
private Boolean fedDoNotCall;
private Date cmsPtcExpire;
private String phoneHome;
private String phoneMobile;
private String phoneWork;
private String phoneOther;
private String phoneFax;
private String email1;
private String email2;
private Boolean emailOptOut;
private Boolean doNotMail;
private Character gender;
private Character type;
private Integer primaryContact;
private int firstTouchTpid;
private int lastTouchTpid;

public CnxContact() {
}

public CnxContact(long orgid, boolean deleted, Date dateEntered,
Date dateModified, int firstTouchTpid, int lastTouchTpid) {
this.orgid = orgid;
this.deleted = deleted;
this.dateEntered = dateEntered;
this.dateModified = dateModified;
this.firstTouchTpid = firstTouchTpid;
this.lastTouchTpid = lastTouchTpid;
}

public CnxContact(Account account, String contactGuid, long orgid,
Date dateOwnerModified, Integer homeAddressUid,
Integer altAddressUid, Integer busAddressUid,
Integer mailingAddressUid, String leadId, String customerId,
boolean deleted, Date dateEntered, Date dateModified,
Long modifiedUserId, Long createdBy, String firstName,
Character middleInitial, String lastName, String suffix,
String title, Date birthdate, String ssn, Boolean doNotCall,
Boolean fedDoNotCall, Date cmsPtcExpire, String phoneHome,
String phoneMobile, String phoneWork, String phoneOther,
String phoneFax, String email1, String email2, Boolean emailOptOut,
Boolean doNotMail, Character gender, Character type,
Integer primaryContact, int firstTouchTpid, int lastTouchTpid) {
this.account = account;
this.contactGuid = contactGuid;
this.orgid = orgid;
this.dateOwnerModified = dateOwnerModified;
this.homeAddressUid = homeAddressUid;
this.altAddressUid = altAddressUid;
this.busAddressUid = busAddressUid;
this.mailingAddressUid = mailingAddressUid;
this.leadId = leadId;
this.customerId = customerId;
this.deleted = deleted;
this.dateEntered = dateEntered;
this.dateModified = dateModified;
this.modifiedUserId = modifiedUserId;
this.createdBy = createdBy;
this.firstName = firstName;
this.middleInitial = middleInitial;
this.lastName = lastName;
this.suffix = suffix;
this.title = title;
this.birthdate = birthdate;
this.ssn = ssn;
this.doNotCall = doNotCall;
this.fedDoNotCall = fedDoNotCall;
this.cmsPtcExpire = cmsPtcExpire;
this.phoneHome = phoneHome;
this.phoneMobile = phoneMobile;
this.phoneWork = phoneWork;
this.phoneOther = phoneOther;
this.phoneFax = phoneFax;
this.email1 = email1;
this.email2 = email2;
this.emailOptOut = emailOptOut;
this.doNotMail = doNotMail;
this.gender = gender;
this.type = type;
this.primaryContact = primaryContact;
this.firstTouchTpid = firstTouchTpid;
this.lastTouchTpid = lastTouchTpid;
}

@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "contact_id", unique = true, nullable = false)
public Integer getContactId() {
return this.contactId;
}

public void setContactId(Integer contactId) {
this.contactId = contactId;
}

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "aid")
public Account getAccount() {
return this.account;
}

public void setAccount(Account account) {
this.account = account;
}

@Column(name = "contact_guid", length = 36)
public String getContactGuid() {
return this.contactGuid;
}

public void setContactGuid(String contactGuid) {
this.contactGuid = contactGuid;
}

@Column(name = "orgid", nullable = false, precision = 10, scale = 0)
public long getOrgid() {
return this.orgid;
}

public void setOrgid(long orgid) {
this.orgid = orgid;
}

@Temporal(TemporalType.TIMESTAMP)
@Column(name = "date_owner_modified", length = 19)
public Date getDateOwnerModified() {
return this.dateOwnerModified;
}

public void setDateOwnerModified(Date dateOwnerModified) {
this.dateOwnerModified = dateOwnerModified;
}

@Column(name = "home_address_uid")
public Integer getHomeAddressUid() {
return this.homeAddressUid;
}

public void setHomeAddressUid(Integer homeAddressUid) {
this.homeAddressUid = homeAddressUid;
}

@Column(name = "alt_address_uid")
public Integer getAltAddressUid() {
return this.altAddressUid;
}

public void setAltAddressUid(Integer altAddressUid) {
this.altAddressUid = altAddressUid;
}

@Column(name = "bus_address_uid")
public Integer getBusAddressUid() {
return this.busAddressUid;
}

public void setBusAddressUid(Integer busAddressUid) {
this.busAddressUid = busAddressUid;
}

@Column(name = "mailing_address_uid")
public Integer getMailingAddressUid() {
return this.mailingAddressUid;
}

public void setMailingAddressUid(Integer mailingAddressUid) {
this.mailingAddressUid = mailingAddressUid;
}

@Column(name = "lead_id", length = 50)
public String getLeadId() {
return this.leadId;
}

public void setLeadId(String leadId) {
this.leadId = leadId;
}

@Column(name = "customer_id", length = 50)
public String getCustomerId() {
return this.customerId;
}

public void setCustomerId(String customerId) {
this.customerId = customerId;
}

@Column(name = "deleted", nullable = false)
public boolean isDeleted() {
return this.deleted;
}

public void setDeleted(boolean deleted) {
this.deleted = deleted;
}

@Temporal(TemporalType.TIMESTAMP)
@Column(name = "date_entered", nullable = false, length = 19)
public Date getDateEntered() {
return this.dateEntered;
}

public void setDateEntered(Date dateEntered) {
this.dateEntered = dateEntered;
}

@Temporal(TemporalType.TIMESTAMP)
@Column(name = "date_modified", nullable = false, length = 19)
public Date getDateModified() {
return this.dateModified;
}

public void setDateModified(Date dateModified) {
this.dateModified = dateModified;
}

@Column(name = "modified_user_id", precision = 10, scale = 0)
public Long getModifiedUserId() {
return this.modifiedUserId;
}

public void setModifiedUserId(Long modifiedUserId) {
this.modifiedUserId = modifiedUserId;
}

@Column(name = "created_by", precision = 10, scale = 0)
public Long getCreatedBy() {
return this.createdBy;
}

public void setCreatedBy(Long createdBy) {
this.createdBy = createdBy;
}

@Column(name = "first_name", length = 50)
public String getFirstName() {
return this.firstName;
}

public void setFirstName(String firstName) {
this.firstName = firstName;
}

@Column(name = "middle_initial", length = 1)
public Character getMiddleInitial() {
return this.middleInitial;
}

public void setMiddleInitial(Character middleInitial) {
this.middleInitial = middleInitial;
}

@Column(name = "last_name", length = 50)
public String getLastName() {
return this.lastName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}

@Column(name = "suffix", length = 20)
public String getSuffix() {
return this.suffix;
}

public void setSuffix(String suffix) {
this.suffix = suffix;
}

@Column(name = "title", length = 20)
public String getTitle() {
return this.title;
}

public void setTitle(String title) {
this.title = title;
}

@Temporal(TemporalType.DATE)
@Column(name = "birthdate", length = 10)
public Date getBirthdate() {
return this.birthdate;
}

public void setBirthdate(Date birthdate) {
this.birthdate = birthdate;
}

@Column(name = "ssn", length = 12)
public String getSsn() {
return this.ssn;
}

public void setSsn(String ssn) {
this.ssn = ssn;
}

@Column(name = "do_not_call")
public Boolean getDoNotCall() {
return this.doNotCall;
}

public void setDoNotCall(Boolean doNotCall) {
this.doNotCall = doNotCall;
}

@Column(name = "fed_do_not_call")
public Boolean getFedDoNotCall() {
return this.fedDoNotCall;
}

public void setFedDoNotCall(Boolean fedDoNotCall) {
this.fedDoNotCall = fedDoNotCall;
}

@Temporal(TemporalType.DATE)
@Column(name = "cms_ptc_expire", length = 10)
public Date getCmsPtcExpire() {
return this.cmsPtcExpire;
}

public void setCmsPtcExpire(Date cmsPtcExpire) {
this.cmsPtcExpire = cmsPtcExpire;
}

@Column(name = "phone_home", length = 25)
public String getPhoneHome() {
return this.phoneHome;
}

public void setPhoneHome(String phoneHome) {
this.phoneHome = phoneHome;
}

@Column(name = "phone_mobile", length = 25)
public String getPhoneMobile() {
return this.phoneMobile;
}

public void setPhoneMobile(String phoneMobile) {
this.phoneMobile = phoneMobile;
}

@Column(name = "phone_work", length = 25)
public String getPhoneWork() {
return this.phoneWork;
}

public void setPhoneWork(String phoneWork) {
this.phoneWork = phoneWork;
}

@Column(name = "phone_other", length = 25)
public String getPhoneOther() {
return this.phoneOther;
}

public void setPhoneOther(String phoneOther) {
this.phoneOther = phoneOther;
}

@Column(name = "phone_fax", length = 25)
public String getPhoneFax() {
return this.phoneFax;
}

public void setPhoneFax(String phoneFax) {
this.phoneFax = phoneFax;
}

@Column(name = "email1", length = 100)
public String getEmail1() {
return this.email1;
}

public void setEmail1(String email1) {
this.email1 = email1;
}

@Column(name = "email2", length = 100)
public String getEmail2() {
return this.email2;
}

public void setEmail2(String email2) {
this.email2 = email2;
}

@Column(name = "email_opt_out")
public Boolean getEmailOptOut() {
return this.emailOptOut;
}

public void setEmailOptOut(Boolean emailOptOut) {
this.emailOptOut = emailOptOut;
}

@Column(name = "do_not_mail")
public Boolean getDoNotMail() {
return this.doNotMail;
}

public void setDoNotMail(Boolean doNotMail) {
this.doNotMail = doNotMail;
}

@Column(name = "gender", length = 1)
public Character getGender() {
return this.gender;
}

public void setGender(Character gender) {
this.gender = gender;
}

@Column(name = "type", length = 1)
public Character getType() {
return this.type;
}

public void setType(Character type) {
this.type = type;
}

@Column(name = "primary_contact")
public Integer getPrimaryContact() {
return this.primaryContact;
}

public void setPrimaryContact(Integer primaryContact) {
this.primaryContact = primaryContact;
}

@Column(name = "first_touch_tpid", nullable = false)
public int getFirstTouchTpid() {
return this.firstTouchTpid;
}

public void setFirstTouchTpid(int firstTouchTpid) {
this.firstTouchTpid = firstTouchTpid;
}

@Column(name = "last_touch_tpid", nullable = false)
public int getLastTouchTpid() {
return this.lastTouchTpid;
}

public void setLastTouchTpid(int lastTouchTpid) {
this.lastTouchTpid = lastTouchTpid;
}

}
************************************************************
Using this code to fetch records from database:

Session session = HibernateUtil.getSessionFactory().openSession();
CnxContact contact = (CnxContact)session.get(CnxContact.class, new Integer(6));
***************************************************************

It's only stack trace:
java.lang.StringIndexOutOfBoundsException: String index out of range: 0


Top
 Profile  
 
 Post subject: Re: Getting error while selecting data fromtable.
PostPosted: Thu Feb 25, 2010 9:57 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Code:
try {
   CnxContact contact = (CnxContact)session.get(CnxContact.class, new Integer(6));
}
catch (StringIndexOutOfBoundsException ex)
{
  ex.printStackTrace();
}


This will report the exception with complete stacktrace to the standard error stream (stderr)...
Please report the stacktrace.


Top
 Profile  
 
 Post subject: Re: Getting error while selecting data fromtable.
PostPosted: Thu Feb 25, 2010 10:01 am 
Newbie

Joined: Thu Feb 25, 2010 9:05 am
Posts: 9
Thanks for generating me complete stacktrace:

java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(Unknown Source)
at org.hibernate.type.CharacterType.get(CharacterType.java:29)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:113)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:102)
at org.hibernate.type.AbstractType.hydrate(AbstractType.java:81)
at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2031)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1371)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1299)
at org.hibernate.loader.Loader.getRow(Loader.java:1197)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:568)
at org.hibernate.loader.Loader.doQuery(Loader.java:689)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1784)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2977)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:393)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:374)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:137)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:193)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:101)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:815)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:808)
at persistent.service.Sample.main(Sample.java:35)


Top
 Profile  
 
 Post subject: Re: Getting error while selecting data fromtable.
PostPosted: Thu Feb 25, 2010 10:25 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
I believe it's due the fields you declare as Character, for example
Code:
@Column(name = "middle_initial", length = 1)
public Character getMiddleInitial() {
return this.middleInitial;
}


For Character is has absolutely no sense to specify a length.
Try to omit the length = 1 attribute on all your Character fields and let me know it works afterwards...


Top
 Profile  
 
 Post subject: Re: Getting error while selecting data fromtable.
PostPosted: Thu Feb 25, 2010 10:28 am 
Newbie

Joined: Thu Feb 25, 2010 9:05 am
Posts: 9
I am still not getting why this error is coming.

Thanks in advance.


Top
 Profile  
 
 Post subject: Re: Getting error while selecting data fromtable.
PostPosted: Thu Feb 25, 2010 10:30 am 
Newbie

Joined: Thu Feb 25, 2010 9:05 am
Posts: 9
After Changing CnxContact class This error is still occurring.

Below is stacktrace for the same.

Hibernate: select cnxcontact0_.contact_id as contact1_2_0_, cnxcontact0_.aid as aid2_0_, cnxcontact0_.alt_address_uid as alt2_2_0_, cnxcontact0_.birthdate as birthdate2_0_, cnxcontact0_.bus_address_uid as bus4_2_0_, cnxcontact0_.cms_ptc_expire as cms5_2_0_, cnxcontact0_.contact_guid as contact6_2_0_, cnxcontact0_.created_by as created7_2_0_, cnxcontact0_.customer_id as customer8_2_0_, cnxcontact0_.date_entered as date9_2_0_, cnxcontact0_.date_modified as date10_2_0_, cnxcontact0_.date_owner_modified as date11_2_0_, cnxcontact0_.deleted as deleted2_0_, cnxcontact0_.do_not_call as do13_2_0_, cnxcontact0_.do_not_mail as do14_2_0_, cnxcontact0_.email1 as email15_2_0_, cnxcontact0_.email2 as email16_2_0_, cnxcontact0_.email_opt_out as email17_2_0_, cnxcontact0_.fed_do_not_call as fed18_2_0_, cnxcontact0_.first_name as first19_2_0_, cnxcontact0_.first_touch_tpid as first20_2_0_, cnxcontact0_.gender as gender2_0_, cnxcontact0_.home_address_uid as home22_2_0_, cnxcontact0_.last_name as last23_2_0_, cnxcontact0_.last_touch_tpid as last24_2_0_, cnxcontact0_.lead_id as lead25_2_0_, cnxcontact0_.mailing_address_uid as mailing26_2_0_, cnxcontact0_.middle_initial as middle27_2_0_, cnxcontact0_.modified_user_id as modified28_2_0_, cnxcontact0_.orgid as orgid2_0_, cnxcontact0_.phone_fax as phone30_2_0_, cnxcontact0_.phone_home as phone31_2_0_, cnxcontact0_.phone_mobile as phone32_2_0_, cnxcontact0_.phone_other as phone33_2_0_, cnxcontact0_.phone_work as phone34_2_0_, cnxcontact0_.primary_contact as primary35_2_0_, cnxcontact0_.ssn as ssn2_0_, cnxcontact0_.suffix as suffix2_0_, cnxcontact0_.title as title2_0_, cnxcontact0_.type as type2_0_ from uhc_staging_2.cnx_contact cnxcontact0_ where cnxcontact0_.contact_id=?
java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(Unknown Source)
at org.hibernate.type.CharacterType.get(CharacterType.java:29)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:113)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:102)
at org.hibernate.type.AbstractType.hydrate(AbstractType.java:81)
at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2031)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1371)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1299)
at org.hibernate.loader.Loader.getRow(Loader.java:1197)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:568)
at org.hibernate.loader.Loader.doQuery(Loader.java:689)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1784)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2977)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:393)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:374)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:137)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:193)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:101)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:815)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:808)
at persistent.service.Sample.main(Sample.java:35)


Top
 Profile  
 
 Post subject: Re: Getting error while selecting data fromtable.
PostPosted: Thu Feb 25, 2010 10:36 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Please repost your actual mapping,
I'm quite sure there is some residual character type mapped wrong.


Top
 Profile  
 
 Post subject: Re: Getting error while selecting data fromtable.
PostPosted: Thu Feb 25, 2010 10:37 am 
Newbie

Joined: Thu Feb 25, 2010 9:05 am
Posts: 9
package persistent.core;

// Generated Feb 25, 2010 7:23:39 PM by Hibernate Tools 3.2.2.GA

import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
* CnxContact generated by hbm2java
*/
@Entity
@Table(name = "cnx_contact", catalog = "uhc_staging_2")
public class CnxContact implements java.io.Serializable {

private Integer contactId;
private Account account;
private String contactGuid;
private long orgid;
private Date dateOwnerModified;
private Integer homeAddressUid;
private Integer altAddressUid;
private Integer busAddressUid;
private Integer mailingAddressUid;
private String leadId;
private String customerId;
private boolean deleted;
private Date dateEntered;
private Date dateModified;
private Long modifiedUserId;
private Long createdBy;
private String firstName;
private Character middleInitial;
private String lastName;
private String suffix;
private String title;
private Date birthdate;
private String ssn;
private Boolean doNotCall;
private Boolean fedDoNotCall;
private Date cmsPtcExpire;
private String phoneHome;
private String phoneMobile;
private String phoneWork;
private String phoneOther;
private String phoneFax;
private String email1;
private String email2;
private Boolean emailOptOut;
private Boolean doNotMail;
private Character gender;
private Character type;
private Integer primaryContact;
private int firstTouchTpid;
private int lastTouchTpid;

public CnxContact() {
}

public CnxContact(long orgid, boolean deleted, Date dateEntered,
Date dateModified, int firstTouchTpid, int lastTouchTpid) {
this.orgid = orgid;
this.deleted = deleted;
this.dateEntered = dateEntered;
this.dateModified = dateModified;
this.firstTouchTpid = firstTouchTpid;
this.lastTouchTpid = lastTouchTpid;
}

public CnxContact(Account account, String contactGuid, long orgid,
Date dateOwnerModified, Integer homeAddressUid,
Integer altAddressUid, Integer busAddressUid,
Integer mailingAddressUid, String leadId, String customerId,
boolean deleted, Date dateEntered, Date dateModified,
Long modifiedUserId, Long createdBy, String firstName,
Character middleInitial, String lastName, String suffix,
String title, Date birthdate, String ssn, Boolean doNotCall,
Boolean fedDoNotCall, Date cmsPtcExpire, String phoneHome,
String phoneMobile, String phoneWork, String phoneOther,
String phoneFax, String email1, String email2, Boolean emailOptOut,
Boolean doNotMail, Character gender, Character type,
Integer primaryContact, int firstTouchTpid, int lastTouchTpid) {
this.account = account;
this.contactGuid = contactGuid;
this.orgid = orgid;
this.dateOwnerModified = dateOwnerModified;
this.homeAddressUid = homeAddressUid;
this.altAddressUid = altAddressUid;
this.busAddressUid = busAddressUid;
this.mailingAddressUid = mailingAddressUid;
this.leadId = leadId;
this.customerId = customerId;
this.deleted = deleted;
this.dateEntered = dateEntered;
this.dateModified = dateModified;
this.modifiedUserId = modifiedUserId;
this.createdBy = createdBy;
this.firstName = firstName;
this.middleInitial = middleInitial;
this.lastName = lastName;
this.suffix = suffix;
this.title = title;
this.birthdate = birthdate;
this.ssn = ssn;
this.doNotCall = doNotCall;
this.fedDoNotCall = fedDoNotCall;
this.cmsPtcExpire = cmsPtcExpire;
this.phoneHome = phoneHome;
this.phoneMobile = phoneMobile;
this.phoneWork = phoneWork;
this.phoneOther = phoneOther;
this.phoneFax = phoneFax;
this.email1 = email1;
this.email2 = email2;
this.emailOptOut = emailOptOut;
this.doNotMail = doNotMail;
this.gender = gender;
this.type = type;
this.primaryContact = primaryContact;
this.firstTouchTpid = firstTouchTpid;
this.lastTouchTpid = lastTouchTpid;
}

@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "contact_id", unique = true, nullable = false)
public Integer getContactId() {
return this.contactId;
}

public void setContactId(Integer contactId) {
this.contactId = contactId;
}

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "aid")
public Account getAccount() {
return this.account;
}

public void setAccount(Account account) {
this.account = account;
}

@Column(name = "contact_guid", length = 36)
public String getContactGuid() {
return this.contactGuid;
}

public void setContactGuid(String contactGuid) {
this.contactGuid = contactGuid;
}

@Column(name = "orgid", nullable = false, precision = 10, scale = 0)
public long getOrgid() {
return this.orgid;
}

public void setOrgid(long orgid) {
this.orgid = orgid;
}

@Temporal(TemporalType.TIMESTAMP)
@Column(name = "date_owner_modified", length = 19)
public Date getDateOwnerModified() {
return this.dateOwnerModified;
}

public void setDateOwnerModified(Date dateOwnerModified) {
this.dateOwnerModified = dateOwnerModified;
}

@Column(name = "home_address_uid")
public Integer getHomeAddressUid() {
return this.homeAddressUid;
}

public void setHomeAddressUid(Integer homeAddressUid) {
this.homeAddressUid = homeAddressUid;
}

@Column(name = "alt_address_uid")
public Integer getAltAddressUid() {
return this.altAddressUid;
}

public void setAltAddressUid(Integer altAddressUid) {
this.altAddressUid = altAddressUid;
}

@Column(name = "bus_address_uid")
public Integer getBusAddressUid() {
return this.busAddressUid;
}

public void setBusAddressUid(Integer busAddressUid) {
this.busAddressUid = busAddressUid;
}

@Column(name = "mailing_address_uid")
public Integer getMailingAddressUid() {
return this.mailingAddressUid;
}

public void setMailingAddressUid(Integer mailingAddressUid) {
this.mailingAddressUid = mailingAddressUid;
}

@Column(name = "lead_id", length = 50)
public String getLeadId() {
return this.leadId;
}

public void setLeadId(String leadId) {
this.leadId = leadId;
}

@Column(name = "customer_id", length = 50)
public String getCustomerId() {
return this.customerId;
}

public void setCustomerId(String customerId) {
this.customerId = customerId;
}

@Column(name = "deleted", nullable = false)
public boolean isDeleted() {
return this.deleted;
}

public void setDeleted(boolean deleted) {
this.deleted = deleted;
}

@Temporal(TemporalType.TIMESTAMP)
@Column(name = "date_entered", nullable = false, length = 19)
public Date getDateEntered() {
return this.dateEntered;
}

public void setDateEntered(Date dateEntered) {
this.dateEntered = dateEntered;
}

@Temporal(TemporalType.TIMESTAMP)
@Column(name = "date_modified", nullable = false, length = 19)
public Date getDateModified() {
return this.dateModified;
}

public void setDateModified(Date dateModified) {
this.dateModified = dateModified;
}

@Column(name = "modified_user_id", precision = 10, scale = 0)
public Long getModifiedUserId() {
return this.modifiedUserId;
}

public void setModifiedUserId(Long modifiedUserId) {
this.modifiedUserId = modifiedUserId;
}

@Column(name = "created_by", precision = 10, scale = 0)
public Long getCreatedBy() {
return this.createdBy;
}

public void setCreatedBy(Long createdBy) {
this.createdBy = createdBy;
}

@Column(name = "first_name", length = 50)
public String getFirstName() {
return this.firstName;
}

public void setFirstName(String firstName) {
this.firstName = firstName;
}

@Column(name = "middle_initial")
public Character getMiddleInitial() {
return this.middleInitial;
}

public void setMiddleInitial(Character middleInitial) {
this.middleInitial = middleInitial;
}

@Column(name = "last_name", length = 50)
public String getLastName() {
return this.lastName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}

@Column(name = "suffix", length = 20)
public String getSuffix() {
return this.suffix;
}

public void setSuffix(String suffix) {
this.suffix = suffix;
}

@Column(name = "title", length = 20)
public String getTitle() {
return this.title;
}

public void setTitle(String title) {
this.title = title;
}

@Temporal(TemporalType.DATE)
@Column(name = "birthdate", length = 10)
public Date getBirthdate() {
return this.birthdate;
}

public void setBirthdate(Date birthdate) {
this.birthdate = birthdate;
}

@Column(name = "ssn", length = 12)
public String getSsn() {
return this.ssn;
}

public void setSsn(String ssn) {
this.ssn = ssn;
}

@Column(name = "do_not_call")
public Boolean getDoNotCall() {
return this.doNotCall;
}

public void setDoNotCall(Boolean doNotCall) {
this.doNotCall = doNotCall;
}

@Column(name = "fed_do_not_call")
public Boolean getFedDoNotCall() {
return this.fedDoNotCall;
}

public void setFedDoNotCall(Boolean fedDoNotCall) {
this.fedDoNotCall = fedDoNotCall;
}

@Temporal(TemporalType.DATE)
@Column(name = "cms_ptc_expire", length = 10)
public Date getCmsPtcExpire() {
return this.cmsPtcExpire;
}

public void setCmsPtcExpire(Date cmsPtcExpire) {
this.cmsPtcExpire = cmsPtcExpire;
}

@Column(name = "phone_home", length = 25)
public String getPhoneHome() {
return this.phoneHome;
}

public void setPhoneHome(String phoneHome) {
this.phoneHome = phoneHome;
}

@Column(name = "phone_mobile", length = 25)
public String getPhoneMobile() {
return this.phoneMobile;
}

public void setPhoneMobile(String phoneMobile) {
this.phoneMobile = phoneMobile;
}

@Column(name = "phone_work", length = 25)
public String getPhoneWork() {
return this.phoneWork;
}

public void setPhoneWork(String phoneWork) {
this.phoneWork = phoneWork;
}

@Column(name = "phone_other", length = 25)
public String getPhoneOther() {
return this.phoneOther;
}

public void setPhoneOther(String phoneOther) {
this.phoneOther = phoneOther;
}

@Column(name = "phone_fax", length = 25)
public String getPhoneFax() {
return this.phoneFax;
}

public void setPhoneFax(String phoneFax) {
this.phoneFax = phoneFax;
}

@Column(name = "email1", length = 100)
public String getEmail1() {
return this.email1;
}

public void setEmail1(String email1) {
this.email1 = email1;
}

@Column(name = "email2", length = 100)
public String getEmail2() {
return this.email2;
}

public void setEmail2(String email2) {
this.email2 = email2;
}

@Column(name = "email_opt_out")
public Boolean getEmailOptOut() {
return this.emailOptOut;
}

public void setEmailOptOut(Boolean emailOptOut) {
this.emailOptOut = emailOptOut;
}

@Column(name = "do_not_mail")
public Boolean getDoNotMail() {
return this.doNotMail;
}

public void setDoNotMail(Boolean doNotMail) {
this.doNotMail = doNotMail;
}

@Column(name = "gender")
public Character getGender() {
return this.gender;
}

public void setGender(Character gender) {
this.gender = gender;
}

@Column(name = "type")
public Character getType() {
return this.type;
}

public void setType(Character type) {
this.type = type;
}

@Column(name = "primary_contact")
public Integer getPrimaryContact() {
return this.primaryContact;
}

public void setPrimaryContact(Integer primaryContact) {
this.primaryContact = primaryContact;
}

@Column(name = "first_touch_tpid", nullable = false)
public int getFirstTouchTpid() {
return this.firstTouchTpid;
}

public void setFirstTouchTpid(int firstTouchTpid) {
this.firstTouchTpid = firstTouchTpid;
}

@Column(name = "last_touch_tpid", nullable = false)
public int getLastTouchTpid() {
return this.lastTouchTpid;
}

public void setLastTouchTpid(int lastTouchTpid) {
this.lastTouchTpid = lastTouchTpid;
}

}


Top
 Profile  
 
 Post subject: Re: Getting error while selecting data fromtable.
PostPosted: Thu Feb 25, 2010 10:48 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
The mapping seems to be ok.
It seems that your JDBCDriver is returning a empty String (str.length == 0) for the columns of type Character

CharacterType.java
Code:
public Object get(ResultSet rs, String name) throws SQLException {
      String str = rs.getString(name);
      if (str==null) {
         return null;
      }
      else {
         return new Character( str.charAt(0) );   // IndexOutOfBoundException  -> then str.length == 0
      }
   }


Which values did you fill into middle_initial, gender and type when you inserted the records into db?
What character values is the database itself showing if you do a query directly on the database?


Top
 Profile  
 
 Post subject: Re: Getting error while selecting data fromtable.
PostPosted: Wed Mar 03, 2010 9:09 am 
Newbie

Joined: Thu Feb 25, 2010 9:05 am
Posts: 9
Thanks for your help.


Top
 Profile  
 
 Post subject: Re: Getting error while selecting data fromtable.
PostPosted: Wed Mar 03, 2010 9:27 am 
Newbie

Joined: Thu Feb 25, 2010 9:05 am
Posts: 9
I got the actual reason for the above but now i need solution for the same because in database cnx_contact.middle_initial is having value as "" empty string instead of null value.

Is there any solution to handle it from code side.

- Thanks


Top
 Profile  
 
 Post subject: Re: Getting error while selecting data fromtable.
PostPosted: Wed Mar 03, 2010 10:19 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Quote:
Is there any solution to handle it from code side.


In your situations I would initialize (in the constructor) all character properties with a blank.
In this way it should never be persisted an empty string on database and you should get rid of the problem.


Top
 Profile  
 
 Post subject: Re: Getting error while selecting data fromtable.
PostPosted: Wed Mar 03, 2010 10:45 am 
Newbie

Joined: Thu Feb 25, 2010 9:05 am
Posts: 9
could you please tell me how can i reset all character properties with blank value in constructor if no value return by select query.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 16 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.