Subject: RE: Database schema type mappings
You're thinking C++.
In Java:
A long is 8 bytes, always.
An int is 4 bytes, always.
The byte-orders are fixed independent of the hardware, too.
Speaking of byte size, here's something I found amusing (and annoying):
long millisInMonth = 1000 * 60
, or...
Randahl
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Jeff Schnitzer
Sent: 1. marts 2001 02:52
To: Orion-Interest
Subject: RE: Database schema type mappings
From: Randahl Fink Isaksen [mailto:[EMAIL PROTECTED]]
1. Why is Integers automatically converted
To: Orion-Interest
Subject: RE: Database schema type mappings
Jeff, about the bug you mention... that sounds very strange to
me and it
sure should not have anything to do with byte size, I think. The value
millisInMonth easily fits into a long... So if you have a long
representing
the current
ny* appservers
which serialize Integer keys as blobs - although it would work, the
performance penalty would be severe.
Jeff
-Original Message-
From: Randahl Fink Isaksen [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 01, 2001 1:22 AM
To: Orion-Interest
Subject: RE: Database schema type m
- Original Message -
long millisInMonth = (long)1000 * 60 * 60 * 24 * 30;
This should probably go in some sort of Java-puzzle magazine article.
:-)
I think this is a standard situation in Java and C. Most programmers would
probably write it as
long millisInMonth = 1000L * 60L * 60L *
Message-
From: Randahl Fink Isaksen [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 01, 2001 1:09 AM
To: Orion-Interest
Subject: RE: Database schema type mappings
Jeff, about the bug you mention... that sounds very strange to
me and it
sure should not have anything to do with byte size, I
day, March 01, 2001 6:12 AM
To: Orion-Interest
Subject: RE: Database schema type mappings
It's at the bottom of page 159 of Richard Monson-Haefel's _Enterprise
Java Beans, 2nd Ed_: "Although primary keys can be primitive wrappers
(Integer, Double, Long, etc.), primary keys cannot be primi
PROTECTED]]
Sent: Thursday, March 01, 2001 11:46 AM
To: Orion-Interest
Subject: RE: Database schema type mappings
I went digging through the EJB 1.1 specification, and it doesn't
specifically say you can't use primitive types, but it does say they primary
key class needs to be serializable.
I have
millis a
given month actually has since this varies by month and year.
- Original Message -
From: Jeff Schnitzer [EMAIL PROTECTED]
To: Orion-Interest [EMAIL PROTECTED]
Sent: Thursday, March 01, 2001 3:50 AM
Subject: RE: Database schema type mappings
Yes, it fits into a long, but by default
From: Chad Stansbury [mailto:[EMAIL PROTECTED]]
Actually, a more proper way is to indicate to the compiler
that you want
long arithmetic by writing:
long millisInMonth = 1000L * 60L * 60L * 24L * 30L
I'm sure it all gets optimized out to the same thing in the end :-) But
yes, you're right.
: Database schema type mappings
I went digging through the EJB 1.1 specification, and it doesn't
specifically say you can't use primitive types, but it does say they primary
key class needs to be serializable.
I have created a number of EJB's using the primitive long as the primary key
and have had
ubject: RE: Database schema type mappings
It's at the bottom of page 159 of Richard Monson-Haefel's _Enterprise
Java Beans, 2nd Ed_: "Although primary keys can be primitive wrappers
(Integer, Double, Long, etc.), primary keys cannot be primitive types
(int, double, long, etc.)"
I w
If you look at the database schema in
"orion/config/database-schemas/hypersonic.xml" it looks as if it is mapping
between the primitive java type "int" and the corresponding database type
"int":
type-mapping type="int" name="int" /.
In my EJBs my primary keys and other attributes are of type
, 2001 10:02 AM
To: Orion-Interest
Subject: Database schema type mappings
If you look at the database schema in
"orion/config/database-schemas/hypersonic.xml" it looks as if it is mapping
between the primitive java type "int" and the corresponding database type
"int"
:[EMAIL PROTECTED]]
Sent: Wednesday, February 28, 2001 11:02 AM
To: Orion-Interest
Subject: RE: Database schema type mappings
Randahl,
We use the primitive long for all of our primary keys for a couple of
reasons:
* primary keys can't be null so there isn't a need for Long
(or Integer)
* long's
From: Randahl Fink Isaksen [mailto:[EMAIL PROTECTED]]
1. Why is Integers automatically converted to int by Orion -
and is this a
standard EJB convention?
Yes. All the class representations of the primitive types should work
that way.
2. Would it be legal to have a primary key of the
16 matches
Mail list logo