GetInt32() of Integer Column throws InvalidCastException
Hi,
i've trying to solve the error mentioned above. The only way to solve this Problem as a Kind of workarround is
to change the datatype of the fetched column from integer to number(4). Then everything works fine.
Is there a way to get the integer values via getInt32() ??
In the documentation i've found GetInt32 is used to get Int32 Value of a number column.
Does this also mean that it is not possible to get an int32 value of an Integer Column ?
Edited by: 850179 on 21.06.2011 23:24
AFAIK "INTEGER" in Oracle is not a real datatype, it's a synonym for NUMBER(38,0), which is an extremely huge number that won't fit into a .net Int32. Int64 should work.
If you really mean to use an Int32, change the datatype to NUMBER(9,0) or NUMBER(10,0). Note that with NUMBER(10,0) Oracle will let you put in larger numbers then an Int32 so you'll have to watch out for that somewhere in your code (and NUMBER(9,0) is smaller then an Int32 so you pick your poison really).
Similar Messages
-
Integer column for type indication in inheritance structure?
Hi,
I'm struggling with the mapping of an inheritance tree. The classes;
Person and SubPerson use a flat mapping schema, with an metadata-value
indicator for the type of the class. The latter poses some problems. The
database column that contains the type of the class is of type INTEGER
(using
DB2). Apparently Kodo does not support the mapping of metadata-value
indicator to an INTEGER column in the database. Is this correct?
Schema:
<table>
<column name="TYPE" type="INTEGER"/>
</table>
Mapping:
<class name="Person">
<jdbc-class-map type="base" table="PERSON"/>
<jdbc-version-ind type="none"/>
<jdbc-class-ind type="metadata-value" column="TYPE"/>
<class/>
<class name="SubPerson">
<jdbc-class-map type="flat" table="PERSON"/>
<jdbc-version-ind type="none"/>
<class/>
Metadata:
<class name="SubPerson" persistence-capable-superclass="Person">
<extension vendor-name="kodo" key="data-cache-timeout" value="
-1"/>
<extension vendor-name="kodo" key="jdbc-class-ind-value"
value="1"/>
</class>
=> exception when running:
"The "class-column" attribute/extension for the class indicator on type
"Person.<class-indicator>" names a column whose type is not compatible with
the expected type.
Kind Regards,
StijnYou would have to put a numerical value as Person' jdbc-class-ind-value
extension, even if its abstract.
Stijn Van den Enden wrote:
Hi,
I'm struggling with the mapping of an inheritance tree. The classes;
Person and SubPerson use a flat mapping schema, with an metadata-value
indicator for the type of the class. The latter poses some problems. The
database column that contains the type of the class is of type INTEGER
(using
DB2). Apparently Kodo does not support the mapping of metadata-value
indicator to an INTEGER column in the database. Is this correct?
Schema:
<table>
<column name="TYPE" type="INTEGER"/>
</table>
Mapping:
<class name="Person">
<jdbc-class-map type="base" table="PERSON"/>
<jdbc-version-ind type="none"/>
<jdbc-class-ind type="metadata-value" column="TYPE"/>
<class/>
<class name="SubPerson">
<jdbc-class-map type="flat" table="PERSON"/>
<jdbc-version-ind type="none"/>
<class/>
Metadata:
<class name="SubPerson" persistence-capable-superclass="Person">
<extension vendor-name="kodo" key="data-cache-timeout" value="
-1"/>
<extension vendor-name="kodo" key="jdbc-class-ind-value"
value="1"/>
</class>
=> exception when running:
"The "class-column" attribute/extension for the class indicator on type
"Person.<class-indicator>" names a column whose type is not compatible with
the expected type.
Kind Regards,
Stijn
Steve Kim
[email protected]
SolarMetric Inc.
http://www.solarmetric.com -
OracleDataReader GetInt32 throws invalidcastexception
The example below shows an example of calling the OracleDataReader GetInt32 accessor where field 0 is defined as a NUMBER type in the db. This throws an InvalidCastException with the message "specified cast is invald"
OracleDataReader dr = cmd.ExecuteReader();
dr.Read();
int id = dr.GetInt32(0);
dr.Close();
The documentation specifies that this accessor returns an int from a NUMBER column.
I can work around this using a GetDecimal and casting to an int.
Will this bug be fixed in the next release and when is the next release.Chris,
I have tried the code you have posted with a table created as follows:
create table int32_tab(col1 Number(9));
insert into int32_tab values(999999999);
and do not see the InvalidCastException. Could you please provide me with more details of your test case.
-Naveen -
Hi,
I have table with two columns.
Ist column is String type and IInd is Integer type.
I have set this using getColumnClass method in the Table Model.
In the begining when I am adding rows,even if the IInd column is non-numeric it's not showing the red rectangle.
But if I edit the table and value is non-numeric red rectangle is visible. Can Anybody help me to show the red rectangle even in the begining.
Thanks
SmithaThere probably is a better solution.
But I overloaded the getColumnClass(int ColumnIndex) function in the Table Model and return different classes depending on the Column selected...
javax.swing.table.DefaultTableModel model =
new javax.swing.table.DefaultTableModel(){
public Class getColumnClass(int columnIndex)
if(columnIndex == 6) //or whatever column you Choose
return Integer.class;
if(columnIndex == 3)
return Integer.class;
else
return String.class;
TableSorter sorter = new TableSorter(model);
javax.swing.JTable table = new javax.swing.JTable(sorter);
I hope this helps... -
Derived Logical Column throws an error
Hello
I get the 46036 error from Answers when I add a field that I created in the BMM of the RPD. We are on OBIEE 10.3.4.2. I added a logical column to a table and applied a filter for a particular age band. I can check the change in without any errors but when I use that field with that expression I get the nQSError.
*[nQSError: 46036] Internal Assertion Condition pExpr->IsValueExpr(), file*
Ahsan/Naveen, any ideas on this? You guys have been always helpful with my questions.
Thanks,
DanNot sure if this helps but found a few things online on this..may just require a resave or re-import of the specific report (http://tipsonobiee.blogspot.com/2009/06/error-nqserror-46036-internal-assertion.html). If you are on Solaris 64 there is also a bug associated with this. "[nQSError 46036] Internal Assertion Error" After Upgrading to OBIEE 10.1.3.3.2 [ID 566463.1] suggesting to change the following parameter:
A workaround is to make only off line changes.
The bug states the following:
"The solution was to set the following in NQSConfig.INI
SERVER_THREAD_STACK_SIZE = 1024 KB"
This is not the same exact OBIEE version. Try these 2 suggestions and let us know how it goes. -
The XML column is stored as CLOB:
SQL> SELECT column_name,
2 storage_type
3 FROM user_xml_tab_cols
4 WHERE table_name = 'DEMO';
COLUMN_NAME STORAGE_TYPE
COL2 CLOB
I'm running the following procedure.
DECLARE
v_lcr SYS.LCR$_ROW_RECORD;
v_new SYS.LCR$_ROW_LIST := SYS.LCR$_ROW_LIST();
v_xml XMLTYPE;
BEGIN
v_new.EXTEND;
v_new(1) := SYS.LCR$_ROW_UNIT( column_name => 'COL1',
data => ANYDATA.CONVERTNUMBER(1),
lob_information => DBMS_LCR.NOT_A_LOB,
lob_offset => NULL,
lob_operation_size => NULL,
long_information => DBMS_LCR.not_a_long );
v_new.EXTEND;
v_new(2) := SYS.LCR$_ROW_UNIT( column_name => 'COL2',
data => ANYDATA.CONVERTOBJECT(v_xml),
lob_information => DBMS_LCR.EMPTY_LOB,
lob_offset => NULL,
lob_operation_size => NULL,
long_information => DBMS_LCR.not_a_long );
v_lcr := SYS.LCR$_ROW_RECORD.CONSTRUCT(
SOURCE_DATABASE_NAME => 'WHATEVER',
COMMAND_TYPE => 'INSERT',
OBJECT_OWNER => 'DRH_R9',
OBJECT_NAME => 'demo',
NEW_VALUES => v_new );
v_lcr.EXECUTE(FALSE);
END;
The error comes from the EXECUTE call. If I remove the xmltype column everything works fine. Am I missing something?
ThanksAs per the 11.1 documentation xmltype stored as lob is not supported in user enqueued messages:
See Table 11.1 LOB Data Type Representations in Row LCRs
Oracle® Streams Replication Administrator's Guide 11g Release 1 (11.1)
Chapter 11
It is though supported in captured messages -
Determining column throwing error
Hi all,
Given the following script :
create table my_test (
d1 date,
d2 date
alter session set nls_date_format='DD/MM/YYYY';
insert into my_test(d1,d2) values('01/01/2008','01/0/2009');
OUTPUT :
create table succeeded.
alter session set succeeded.
Error starting at line 1 in command:
insert into my_test(d1,d2) values('01/01/2008','01/0/2009')
Error report:
SQL Error: ORA-01843: ce n'est pas un mois valide
01843. 00000 - "not a valid month"
*Cause:
*Action:I have tried to insert an incorrect date voluntarily: the second date. Obviously, i can change this date and make my "insert".
But i'd like to know if somewhere, Oracle stores the information of the faulting field (d2). In this case, is it possible to retrieve this information and how ?
Stephan, so you get your line number...I suppose the line number will be the line number of where the failing statement begins, so it won't be really of a big help:
SQL> begin
insert into my_test
values (
to_date ('01/01/2008', 'DD/MM/RRRR'),
to_date ('01/0/2009', 'DD/MM/RRRR')
end;
Error at line 1
ORA-01843: not a valid month
ORA-06512: at line 2 -
How do you use an entity bea that uses an identity column?
I am using an mssql database. I need to create an entity bean for a table that uses an identity column. I want to use the identity column as the Primary key in the entity bean.
I assumed that I should not pass in a paramter for the identity column into the create method of the Home interface or the create method of the Bean ejbCreate method. But when I try using the entitity bean to create a new row in the table I get the following error.
Cannot insert explicit value for identity column in table 'PropsTableIdentity when IDENTITY_INSERTis set to OFF.
I didn't think I was doing anything to explicitly insert anything into the identity column.
Anyways here are my programs if anybody cares to take a look.
PropsIdentity.java
package propsIdentity;
// File generated by Desiderata Software's Blazix entity bean wizard
// Thu May 05 08:20:44 MDT 2005
// Remote interface for entity bean "PropsIdentity"
import javax.ejb.*;
import java.rmi.*;
public interface PropsIdentity extends javax.ejb.EJBObject {
int getKey() throws java.rmi.RemoteException;
java.lang.String getValue() throws java.rmi.RemoteException;
void setValue( java.lang.String value ) throws java.rmi.RemoteException;
// TBD: Add any additional remote method interfaces
PropsIdentityHome.java
package propsIdentity;
// File generated by Desiderata Software's Blazix entity bean wizard
// Thu May 05 08:20:44 MDT 2005
// Home interface for entity bean "PropsIdentity"
import javax.ejb.*;
import java.rmi.*;
import java.util.*;
public interface PropsIdentityHome extends javax.ejb.EJBHome {
PropsIdentity create(
java.lang.String value
) throws javax.ejb.CreateException, java.rmi.RemoteException;
PropsIdentity findByPrimaryKey( java.lang.Integer pkey ) throws javax.ejb.FinderException, java.rmi
.RemoteException;
}PropsIdentityHome.java
code]
package propsIdentity;
// File generated by Desiderata Software's Blazix entity bean wizard
// Thu May 05 08:20:44 MDT 2005
// Home interface for entity bean "PropsIdentity"
import javax.ejb.*;
import java.rmi.*;
import java.util.*;
public interface PropsIdentityHome extends javax.ejb.EJBHome {
PropsIdentity create(
java.lang.String value
) throws javax.ejb.CreateException, java.rmi.RemoteException;
PropsIdentity findByPrimaryKey( java.lang.Integer pkey ) throws javax.ejb.FinderException, java.rmi
.RemoteException;
PropsIdentityBean.java
package propsIdentity;
// File generated by Desiderata Software's Blazix entity bean wizard
// Thu May 05 08:20:44 MDT 2005
// Home interface for entity bean "PropsIdentity"
import javax.ejb.*;
import java.rmi.*;
import java.util.*;
public interface PropsIdentityHome extends javax.ejb.EJBHome {
PropsIdentity create(
java.lang.String value
) throws javax.ejb.CreateException, java.rmi.RemoteException;
PropsIdentity findByPrimaryKey( java.lang.Integer pkey ) throws javax.ejb.FinderException, java.rmi
.RemoteException;
}PropsIdentityBean.java
// Thu May 05 08:20:44 MDT 2005
// Bean class for entity bean "PropsIdentity"
import javax.ejb.*;
import javax.naming.*;
import java.rmi.*;
public class PropsIdentityBean implements javax.ejb.EntityBean {
//Instance member variables.
public int key = 0;
public java.lang.String value = null;
// Entity context, can be used to obtain handles etc
javax.ejb.EntityContext ejbEntityContext = null;
//Getter/setter methods
public int getKey() throws java.rmi.RemoteException
return key;
public java.lang.String getValue() throws java.rmi.RemoteException
return value;
public void setValue( java.lang.String value ) throws java.rmi.RemoteException
this.value = value;
// TBD: Add implementations for any additional remote method interfaces
// The default ejbCreate method.
public java.lang.Integer ejbCreate(
java.lang.String value
throws javax.ejb.CreateException, java.rmi.RemoteException
this.value = value;
return null;
// TBD: If any other ejbCreate's are added manually to the home interface, define them.
// Other methods required in an entity bean
public void setEntityContext( javax.ejb.EntityContext ejbEntityContext )
throws RemoteException
this.ejbEntityContext = ejbEntityContext;
public void unsetEntityContext()
throws RemoteException
this.ejbEntityContext = null;
public void ejbPostCreate(
java.lang.String value
// TBD: Do any post-instance-creation processing here
public void ejbRemove()
throws java.rmi.RemoteException, javax.ejb.RemoveException
// TBD: Do any processing here when instance is being removed
public void ejbActivate()
throws java.rmi.RemoteException
// TBD: Do any processing here when instance is activated
public void ejbPassivate()
throws java.rmi.RemoteException
// TBD: Do any processing here when instance is being passivated
public void ejbLoad()
throws java.rmi.RemoteException
// TBD: Load any data needed by instance
// in addition to the container-managed data.
public void ejbStore()
throws java.rmi.RemoteException
// TBD: Store any data used by instance
// in addition to the container-managed data.
} Script used to create table in mssql
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PropsTableIdentity]') and OBJE
CTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[PropsTableIdentity]
GO
CREATE TABLE [dbo].[PropsTableIdentity] (
[key] [int] IDENTITY (1, 1) NOT NULL ,
[value] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY]
GOAnybody have any clue on how to figure the entity bean to work with the identity column?Hi,
CAN THIS BE DONE? This would be a good enhancement if not...???
If I write a PL/SQL loop and want to add it to the utilities... IS THERE A WAY? -
Java.lang.NullPointerException throwed when doing Hibernate Persistence
Im using Hibernate3.
I am trying to add a record of "orderdetail", also setting its many-2-one association "order", which include a many-2-one association with "employer".
Mycode is:
public class OrderdetailDaoTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
try{
Orderdetails vo = new Orderdetails();
IOrdersDAO orderdao = new OrdersDAO();
Integer orderid = new Integer("1");
System.out.println("orderid is "+orderid.intValue());
Orders order = (Orders)orderdao.getOrderByid(orderid);
vo.setOrders(order);
IEmployeesDAO eedao = new EmployeesDAO();
Integer eeid = new Integer("1");
Employees employee = eedao.getEmployeeByid(eeid);
vo.setEmployees(employee);
Calendar startdate = Calendar.getInstance();
startdate.set(2007, 5, 15);
//System.out.println("time is "+startdate.getTime());
vo.setStartDate(startdate.getTime());
Calendar enddate = Calendar.getInstance();
startdate.set(2007, 6, 15);
//System.out.println("time is "+enddate.getTime());
vo.setEndDate(enddate.getTime());
Calendar arrdate = Calendar.getInstance();
arrdate.set(2007, 6, 16);
//System.out.println("time is "+arrdate.getTime());
vo.setArrivalDate(arrdate.getTime());
vo.setArrivalStatus("Experienced Named");
Calendar repatdate = Calendar.getInstance();
repatdate.set(2007, 7, 16);
//System.out.println("time is "+arrdate.getTime());
vo.setRepatDate(repatdate.getTime());
vo.setRepatStatus("Other");
vo.setTransferStatus("Named Transfer");
Calendar transferdate = Calendar.getInstance();
transferdate.set(2007, 7, 1);
//System.out.println("time is "+arrdate.getTime());
vo.setDateTransferred(transferdate.getTime());
vo.setNotes("This is a long test note!");
IArrivalmanifesttblDAO arrivaldao = new ArrivalmanifesttblDAO();
Arrivalmanifesttbl arrival = arrivaldao.getArrivalByAMNO("am01");
vo.setArrivalmanifest(arrival);
IRepatmanifesttblDAO repatdao = new RepatmanifesttblDAO();
Repatmanifesttbl repat = repatdao.getRepatByRMNO("rm01");
vo.setRepatmanifest(repat);
vo.setRepatDetail("This is long test repat detail!");
vo.setIncludeInArrivalManifest(new Byte("0"));
vo.setIncludeInRepatManifest(new Byte("0"));
vo.setTransferred(new Byte("1"));
vo.setDelete(new Byte("0"));
vo.setSno(new Short("100"));
IOrderdetailsDAO dao = new OrderdetailsDAO();
dao.add(vo);
catch(ApplicationException e){
e.getStackTrace();
System.out.println("Exception throwed!");
}The stack print like following:
Exception in thread "main" java.lang.NullPointerException
at com.farm.vo.Employers.hashCode(Employers.java:270)
at com.farm.vo.Orders.hashCode(Orders.java:168)
at java.util.HashMap.put(Unknown Source)
at java.util.HashSet.add(Unknown Source)
at java.util.AbstractCollection.addAll(Unknown Source)
at org.hibernate.collection.PersistentSet.endRead(PersistentSet.java:273)
at org.hibernate.engine.CollectionLoadContext.endLoadingCollection(CollectionLoadContext.java:183)
at org.hibernate.engine.CollectionLoadContext.endLoadingCollections(CollectionLoadContext.java:268)
at org.hibernate.engine.CollectionLoadContext.endLoadingCollections(CollectionLoadContext.java:249)
at org.hibernate.loader.Loader.endCollectionLoad(Loader.java:866)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:853)
at org.hibernate.loader.Loader.doQuery(Loader.java:717)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.loadCollection(Loader.java:1919)
at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:36)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:520)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1676)
at org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:454)
at org.hibernate.engine.StatefulPersistenceContext.initializeNonLazyCollections(StatefulPersistenceContext.java:755)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:229)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1785)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:47)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:41)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2730)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:365)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:346)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:123)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:177)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:862)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:799)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:792)
at com.farm.dao.OrdersDAO.getOrderByid(OrdersDAO.java:98)
at com.farm.unitTest.daotest.OrderdetailDaoTest.main(OrderdetailDaoTest.java:33)The mapping file for orderdetail is like:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping>
<class name="com.farm.vo.Orderdetails" table="orderdetails" catalog="llbv1" lazy="false">
<id name="orderDetailId" type="java.lang.Integer">
<column name="OrderDetailID" />
<generator class="native" />
</id>
<many-to-one name="employees" class="com.farm.vo.Employees" lazy="false">
<column name="EmployeeID" />
</many-to-one>
<many-to-one name="orders" class="com.farm.vo.Orders" lazy="false">
<column name="OrderID" />
</many-to-one>
<many-to-one name="repatmanifest" class="com.farm.vo.Repatmanifesttbl" cascade="all" lazy="false">
<column name="RepatManifestNo" length="50" />
</many-to-one>
<many-to-one name="arrivalmanifest" class="com.farm.vo.Arrivalmanifesttbl" cascade="all" lazy="false">
<column name="ArrivalManifestNo" length="50" />
</many-to-one>
<property name="startDate" type="java.util.Date">
<column name="StartDate" length="19" />
</property>
<property name="endDate" type="java.util.Date">
<column name="EndDate" length="19" />
</property>
<property name="arrivalDate" type="java.util.Date">
<column name="ArrivalDate" length="19" />
</property>
<property name="arrivalStatus" type="java.lang.String">
<column name="ArrivalStatus" length="21" />
</property>
<property name="repatDate" type="java.util.Date">
<column name="RepatDate" length="19" />
</property>
<property name="repatStatus" type="java.lang.String">
<column name="RepatStatus" length="18" />
</property>
<property name="transferStatus" type="java.lang.String">
<column name="TransferStatus" length="16" />
</property>
<property name="dateTransferred" type="java.util.Date">
<column name="DateTransferred" length="19" />
</property>
<property name="notes" type="java.lang.String">
<column name="Notes" />
</property>
<property name="repatDetail" type="java.lang.String">
<column name="RepatDetail" />
</property>
<property name="includeInArrivalManifest" type="java.lang.Byte">
<column name="IncludeInArrivalManifest" />
</property>
<property name="includeInRepatManifest" type="java.lang.Byte">
<column name="IncludeInRepatManifest" />
</property>
<property name="transferred" type="java.lang.Byte">
<column name="Transferred" />
</property>
<property name="iomRemarks" type="java.lang.String">
<column name="IOM_Remarks" />
</property>
<property name="observations" type="java.lang.String">
<column name="Observations" />
</property>
<property name="mitigatingFactors" type="java.lang.String">
<column name="MitigatingFactors" />
</property>
<property name="delete" type="java.lang.Byte">
<column name="isDelete" />
</property>
<property name="employeeRemarks" type="java.lang.String">
<column name="EmployeeRemarks" />
</property>
<property name="nbstatus" type="java.lang.String">
<column name="NBStatus" length="50" />
</property>
<property name="sno" type="java.lang.Short">
<column name="SNo" />
</property>
<property name="userComment" type="java.lang.String">
<column name="UserComment" />
</property>
</class>
</hibernate-mapping>I am stuck with this problem for several days. Any seggestion is appreciated!
Thanks in advance.It seems that the exception throwed on the hashcode() for NULL value field include in the association.... The many-2-one assciation is bidirectional, by the way.
Is my hibernate mapping file somewhere implicitly restrict the association fields can not be NULL? If it is, can somebody tells me where?
Following is "orderdetail"'s bidirectinal association definition, "order" mapping file:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping>
<class name="com.farm.vo.Orders" table="orders" catalog="llbv1">
<id name="orderId" type="java.lang.Integer">
<column name="OrderID" />
<generator class="native" />
</id>
<many-to-one name="employer" class="com.farm.vo.Employers" lazy="false">
<column name="EmployerID"/>
</many-to-one>
<property name="hrdcorderCode" type="java.lang.String">
<column name="HRDCOrderCode" length="50" />
</property>
<property name="farmsorderCode" type="java.lang.String">
<column name="FARMSOrderCode" length="50" />
</property>
<property name="orderDate" type="java.util.Date">
<column name="OrderDate" length="19" />
</property>
<property name="startDate" type="java.util.Date">
<column name="StartDate" length="19" />
</property>
<property name="endDate" type="java.util.Date">
<column name="EndDate" length="19" />
</property>
<property name="orderType" type="java.lang.String">
<column name="OrderType" length="20" not-null="true" />
</property>
<property name="noOfWorker" type="java.lang.Short">
<column name="NoOfWorker" />
</property>
<property name="orderStatus" type="java.lang.String">
<column name="OrderStatus" length="12" />
</property>
<property name="notes" type="java.lang.String">
<column name="Notes" />
</property>
<set name="orderdetails" inverse="true" cascade="all-delete-orphan" lazy="false">
<key column="OrderId"/>
<one-to-many class="com.farm.vo.Orderdetails"/>
</set>
</class> Thank you! -
JDBC TYPES.Integer Data Type--Oracle seems useless
I have a set of applications that work on every database I've
tried it on except Orocle. They rely very heavily on making a
query and then grabbing the correct data type (e.g., getInt() vs.
getString()) based on the int value returned in the
ResultSetMetaData. The problem here is that the type returned
for Integer columns, however, is always NUMBER and therefore
always has a decimal place and gets automatically converted into
a double. This wreaks havoc on all of the classes which assume
that certain columns will be int's (e.g., primary keys). Also,
since I'm programming servlets, I am often throwing the values
into forms where the values will be retrieved and have an
Integer.parseInt() run on them--Integer.parseInt() will not work
on Strings with decimal points.
I realize why Oracle does this (because an integer is a number
with no decimals) and what the workaround is (use a
NumberFormatter instead of Integer.parseInt() or use Oracle's
extensions to preset the datatype). But why should I have to
hack up my code just because Oracle programmers can't figure out
how to get its JDBC drivers to return the proper Type code?
Is there any other w
nullI have a set of applications that work on every database I've
tried it on except Orocle. They rely very heavily on making a
query and then grabbing the correct data type (e.g., getInt() vs.
getString()) based on the int value returned in the
ResultSetMetaData. The problem here is that the type returned
for Integer columns, however, is always NUMBER and therefore
always has a decimal place and gets automatically converted into
a double. This wreaks havoc on all of the classes which assume
that certain columns will be int's (e.g., primary keys). Also,
since I'm programming servlets, I am often throwing the values
into forms where the values will be retrieved and have an
Integer.parseInt() run on them--Integer.parseInt() will not work
on Strings with decimal points.
I realize why Oracle does this (because an integer is a number
with no decimals) and what the workaround is (use a
NumberFormatter instead of Integer.parseInt() or use Oracle's
extensions to preset the datatype). But why should I have to
hack up my code just because Oracle programmers can't figure out
how to get its JDBC drivers to return the proper Type code?
Is there any other w
null -
Column Function Return Type Number is forcing to cast to Decimal
Hi - I am using Oracle 11g Release 11.2.0.2.0 and ODP.NET 4.112.3.0.
Whenever I am trying to execute a package query with column function and return type is number, it is throwing cast exception whenever I am trying to cast it as GetInt32.
The workaround we have for now is to get it decimal and cast to Int32, this is going to be painful moving forward because it means that we have to check each of our packages and need to know if each package has column function and do this special casting.
Is this a known bug?Oracle Number is 6.
Run the below script to your machine and the sample code below so you can see what I am talking about.
--drop table aninalfarm;
--drop table birdfarm;
--drop public synonym animalfarm;
--drop public synonym birdfarm;
--drop public synonym birdfarm_Pkg;
--drop public synonym animalfarm_Pkg;
create table animalfarm
(code NUMBER(6),
description varchar2(10));
create table birdfarm
(code number(6),
description varchar2(10));
create public synonym animalfarm for db.animalfarm;
create public synonym birdfarm for db.birdfarm;
grant select, delete, insert, update on animalfarm to public;
grant select, delete, insert, update on birdfarm to public;
delete from animalfarm;
delete from birdfarm;
commit;
insert into animalfarm (code, description) values(111122, 'Horse');
insert into animalfarm (code, description) values(111133, 'Chicken');
insert into animalfarm (code, description) values(111144, 'Cow');
insert into animalfarm (code, description) values(111155, 'Pig');
insert into animalfarm (code, description) values(111166, 'Sheep');
insert into birdfarm (code, description) values(222, 'Pigeon');
insert into birdfarm (code, description) values(333, 'Sparrow');
insert into birdfarm (code, description) values(444, 'Chickadee');
insert into birdfarm (code, description) values(555, 'Blue Jay');
insert into birdfarm (code, description) values(666, 'Loon');
commit;
create or replace package birdfarm_Pkg is
function get_key_from_desc(bird_name_in in birdfarm.description%type) return number;
end birdfarm_Pkg;
create or replace package body birdfarm_Pkg is
function get_key_from_desc(bird_name_in in birdfarm.description%type) return number is
RETURN_VALUE birdfarm.code%TYPE;
BEGIN
select code into RETURN_VALUE from birdfarm where description = bird_name_in;
return RETURN_VALUE;
end get_key_from_desc;
END birdfarm_Pkg;
create or replace package animalfarm_Pkg is
--region Define Record Type for Strong Type REF CURSOR
TYPE AnimalFarmRecord is
RECORD(
code animalfarm.code%type,
description animalfarm.description%type,
birdfarm_code birdfarm.code%type
--endregion
TYPE animalfarmCur is REF CURSOR RETURN AnimalFarmRecord;
procedure get_code_two_ways(cur_OUT OUT animalfarmCur);
end animalfarm_Pkg;
create or replace package body animalfarm_Pkg is
procedure get_code_two_ways(cur_OUT OUT animalfarmCur) is
BEGIN
open cur_OUT for
select animalfarm.code,
animalfarm.description,
birdfarm_pkg.get_key_from_desc('Pigeon') birdfarm_code
from animalfarm
order by code;
end get_code_two_ways;
END animalfarm_Pkg;
create public synonym birdfarm_Pkg for db.birdfarm_Pkg;
grant execute on birdfarm_Pkg to public;
create public synonym animalfarm_Pkg for db.animalfarm_Pkg;
grant execute on animalfarm_Pkg to public;
See the sample code below:
var conn = new OracleConnection(OraDB);
conn.Open();
conn.ClientId = "Sample";
var command = new OracleCommand
Connection = conn,
CommandText = "DB.animalfarm_Pkg.get_code_two_ways",
CommandType = CommandType.StoredProcedure
command.Parameters.Add(new OracleParameter
ParameterName = "cur_OUT",
OracleDbType = OracleDbType.RefCursor,
Direction = ParameterDirection.Output
OracleDataReader dr = command.ExecuteReader(); // C#
dr.Read();
var code =dr.GetInt32(dr.GetOrdinal("Code")); //This is ok
var description = dr.GetString(dr.GetOrdinal("Description"));
var codeError = dr.GetInt32(dr.GetOrdinal("birdfarm_code"));//Throw invalid cast exception
//because it is column function
conn.Close();
conn.Dispose(); -
WHat is the best index type for non uniqueness / Varchar columns in SQL 2008 R2
Hello All Greetings,
Please help me here with my doubt,
in my table i have two columns about a million rows, it has about 20 columns in it, three columns with name as Period, Gender so most of the time these two columns use in where clause,
Gender will contain Either M or F , Period contains YYYY-Month (2013-December, 2013-August) etc so i would like to add a Index to these two columns so that in will increase the performance, so please let me know what type of indexes i need to add to
these columns in the table,
please note that only one time we will add data to the table which will take only 2 minutes but we query the table every day
so my question what is the best index type that i need to create on columns with non uniqueness values in the column.,
Thank you In Advance,
MilanThere is nothing whatever wrong with creating an index on a VARCHAR column, or set of columns.
Regarding the performance of VARCHAR/INT, as with everything in a RDBMS, it depends on what you are doing. What you may be thinking of is the fact that clustering a table on a VARCHAR key is (in SQL Server) marginally less efficient than clustering on a monotonically
increasing numerical key, and can introduce fragmentation.
Or you may be thinking of what you have heard about writing JOINs on VARCHAR columns - it is true, it is a little less efficient than a JOIN on numeric type, but it is only a little less efficient, nothing that would lead you to never join on varchar cols.
None of this does not mean that you should not create indexes on VARCHAR columns. A needed index on a VARCHAR column will boost query performance, often by orders of magnitude. If you need an index on a VARCHAR, create it. It makes no sense to try to find an
integer column to create the index on - the engine will never use it.
Check this reference: http://stackoverflow.com/questions/14041481/is-it-good-to-create-a-nonclustered-index-on-a-column-of-type-varchar
Mark ANSWER if this reply resolves your query, If helpful then VOTE HELPFUL
INSQLSERVER.COM
Mohammad Nizamuddin -
How can I change the type of column in matrix
I want to change the type of column in matrix to it_LINKED_BUTTON, so it can show the orange arrow
I added the column throw marketing documents (rows)
It's seems the default column type is it_Edit
is there a way of changing the column type
i tried the below code, but it did not work because the type property in a matrix column is readonly
mtx.Columns.Item(0).Type = SAPbouiCOM.BoFormItemTypes.it_LINKED_BUTTON
sincerely yours
Riade Aslehi don't want to add a new column
i want to change the column type of existing column in matrix, becuase it's bind to a field
beside that, i can not add column , if the matrix has rows in it
sincerely yours
Riade Asleh -
All, I'm trying fix an issue with transactional replication where replication monitor is showing the push to the subscriber is failing because of the error, "Cannot update identity column." I've tried to use sp_browsereplcmds to pull up the
command that's failing based on the xact_seqno but when I try that I get the error:
Number: 102, State: 1, Procedure: , LineNumber: 0, Server: , Source: .Net SqlClient Data Provider
Message: Incorrect syntax near '┻'.
I'd like to fix the issue without having to rebuild replication during a maintenance window. I know you cannot publish tables with primary keys, but I'm wondering if dropping the identity column on this table might fix the issue. I'm considering
that but I would prefer to be able to pull the command that's trying to update the identity column, throw in SET IDENTITY_INSERT ON and remove the commands from the distribution database, but if that doesn't work I'm open to ideas of just dropping the primary
key on the replicated table. I think that should be fine.
Does anyone have any recommendations on how to view the command that's failing?
Or if dropping the primary key on the subscriber table would create issues with the publisher (since it is also the primary key)?
Or, know of any other ways in which to address this issue? Thanks.Unfortunately, no. The error was a bit of a red herring. In the end the subscriber was missing all of the stored procedures needed to update data in the published tables (i.e., the procedures for performing inserts/updates/deletes were missing
for every table in the subscriber database). Additionally, I could not recreate these stored procedures using sp_scriptpublicationcustomprocs
because another procedure which was required for that proc to work was also missing. In short, there were hundreds of missing stored procedures in the subscriber database on which transactional replication is dependent in order to replicate DML changes and
function normally and this includes system sprocs which would've been used to recreate the missing DML procs. In short, the subscriber was badly damaged and deemed to be unrecoverable within a reasonable time frame.
The solution was to tear down and start over, which we did successfully later in the evening. -
Id column values for null objects
If I have something like the following, where B.id is mapped to an INTEGER
column in A's table, Kodo wants to store a NULL value into the column. This
doesn't work if the column is specified as NOT NULL. Is there a way to
configure Kodo to use some predefined integer value instead, such as 0
or -1?
class A {
int id;
B b;
class B {
int id;
A a = new A();
a.id = 123;
a.b = null;
pm.makePersistent(a);
pm.currentTransaction().commit();I'm not sure what you mean by "value mapping." In my case, I am mapping a
null reference to another object. I am using application identity. Here's a
more complete example (still very abbreviated, but hopefully complete
enough):
class A {
static class Id { int id; }
int id;
B b;
class B {
static class Id { int id; }
int id;
int value;
create table A (ID integer not null, BID integer not null)
create table B (ID integer not null, VALUE integer)
<jdo>
<package name="test">
<class name="A" objectid-class="A$Id">
<extension vendor-name="kodo" key="table" value="A"/>
<field name="id" primary-key="true">
<extension vendor-name="kodo" key="data-column" value="ID"/>
</field>
<field name="b">
<extension vendor-name="kodo" key="id-data-column" value="BID"/>
</field>
</class>
<class name="B" objectid-class="B$Id">
<extension vendor-name="kodo" key="table" value="B"/>
<field name="id" primary-key="true">
<extension vendor-name="kodo" key="data-column" value="ID"/>
</field>
<field name="value">
<extension vendor-name="kodo" key="data-column" value="VALUE"/>
</field>
</class>
</package>
</jdo>
A a1 = new A();
a1.id = 123;
a1.b = new B();
a1.b.id = 456;
a1.b.value = 999;
pm.makePersistent(a1);
A a2 = new A();
a2.id = 789;
a1.b = null;
pm.makePersistent(a2);
pm.currentTransaction().commit();
The inserts for table A look something like this:
insert into A (ID, BID) values (123, 456)
insert into B (ID, VALUE) values (456, 999)
insert into A (ID, BID) values (789, NULL)
The NULL value fails because the column is specified as NOT NULL
(pre-existing schema scenario).
What I need to be able to do is specify what value gets inserted for null
object references. Kodo is inserting NULL. I need to insert -1.
Maybe you are looking for
-
So I got the generic USB tip for the iGo charger. This is just a USB power port. I use a mini dock on my iPod to get line out while I'm in my car, and it has a USB in for charging. However, when I connect the USB it does not charge. Does anyone know
-
Images show up only as blue question marks
I just purchased a new Macbook Pro approximately one week ago, and concitering it's BRAND NEW I don't understand why I have this problem. On sites like www.deviantart.com and also www.weheartit.com images show up as blue question marks... I have down
-
N96 Problem after update to v12
Hi , after i update my n96 to latest v12 , i got just 1 problem , and the problem is , when i open the gallery photo my picture quality not the good as v10 (first firmware). it's like my images , (camera images and other images in phone) , not loaded
-
Certain contact groups on iPhone?
I have 2 groups in my address book: "All Contacts" and "Cell" With iCloud I have all the contact on my phone where I'd only like the "Cell" group. I can easily sort between groups in the Contacts app but it's very annoying when I'm sending a SMS or
-
Credit management information.
Hello gurus, I am new to credit management with BW integration,please any one give me detail information about credit management Data Sources and info objects and cubes and ods. I want to impliment credit management data sources right now and i want