Yes its possible, but not very wise...

What happens when you want to make a field that is a varchar??

A blob is a Binary Large OBject right, if you have the text datatype in your
database this is a way better sollution, but still not a good one....

Varchar is the best mapping for string.

If you use blobs on every one string you store in the database its ok...For
instance :
name: blob
address: blob
sex: blob

See my point?

What you might want to do is make your own BigString that is mapped into an
blob in the database, if you want to do this. Look at the oracle-schema to
find how to do this.


Klaus

-----Opprinnelig melding-----
Fra: Randahl Fink Isaksen [mailto:[EMAIL PROTECTED]]
Sendt: 11. januar 2001 11:27
Til: Orion-Interest
Emne: RE: large field bug ??


Some thoughts...

You are right, that such a work-around would work, but having to keep your
Strings stored in memory as Objects i not very nice - can't the mapping be
changed, so Strings are mapped to Blobs...?

If not, I would use StringBuffer (which is probably mapped to BLOB) instead
of Object to store my Strings.


Randahl

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Juan Lorandi
(Chile)
Sent: 11. januar 2001 08:54
To: Orion-Interest
Subject: RE: large field bug ??


had that problem....

it's a mapping problem... (oracle-schema)


Strings get Mapped to varchars(size)...

They get chopped at size chars...
the only solution is to declare the field as java.lang.Object
then use it as string

public Object name;

public void setName(String name)
{
        this.name = name;
}
public String getName()
{
        return name.toString();
        //or:
        //return (String) name;
}

HTH

JP

-----Original Message-----
From: Agus K. Pranantoseno [mailto:[EMAIL PROTECTED]]
Sent: Miércoles, 10 de Enero de 2001 22:21
To: Orion-Interest
Subject: large field bug ??


I have manage to put my String stored as blob working using cmp.... but if
the size is more than 1k it's go wrong... (the blob does not stored to the
db and the next time i restart the orion those entity even failed to
load)....
i am used orion 1.3.8 with oracle 8.1.6 both on linux machine....
is there any limitation in bean size ?? this is orion bug or oracle jdbc bug
???
i only done simply cmp mapping



--------------------------- THE SOURCE (if u don't mind to
read) ------------------------
public class MediaEJB implements EntityBean {
 transient EntityContext context;

 public int id;
 public MediaFolder folder;
 public String name;
 public Object content;

 public Integer ejbCreate(MediaFolder folder,String name) throws
CreateException {
  try {
   this.id = (int) CounterUtils.getNextID("java:comp/env/ejb/Counter",
"MediaFolder");
  } catch (Exception ex) {
   throw new CreateException("Unable to genereate auto number "+ex);
  }
  try {
   setFolder(folder);
  } catch (Exception ex) {
   throw new CreateException("Error "+ex);
  }
  setName(name);
  return null;
 }
 public void ejbPostCreate(MediaFolder folder,String name) {
 }

 public MediaFolder getFolder() {
  return folder;
 }
 public void setFolder(MediaFolder folder) throws EJBException,
RemoteException {
  MediaFolder itr = folder;
  while (itr != null) {
   if (itr.getId() == id) throw new EJBException("Recursif folder");
   itr = itr.getParent();
  }
  this.folder = folder;
 }

 public int getId() {
  return id;
 }

 public String getName() {
  return name;
 }
 public void setName(String name) throws EJBException {
  if (name == null) throw new EJBException("Parameter name is required");
  if (name.length() == 0) throw new EJBException("Parameter name is
required");
  this.name = name;
 }

 public Object getContent() {
  return content;
 }
 public void setContent(Object content) throws EJBException {
  this.content = content;
 }

 public int getLevel() throws RemoteException {
  if (folder != null) return folder.getLevel() + 1;
  return 1;
 }
 public String getFullName() throws RemoteException {
  if (folder != null) return folder.getFullName() + "/" + getName();
  return getName();
 }
 public String getFullName(String separator) throws RemoteException {
  if (folder != null) return folder.getFullName() + separator + getName();
  return getName();
 }





 public void setEntityContext(EntityContext context) {
  this.context = context;
 }
 public void unsetEntityContext() {
  context = null;
 }

 public void ejbActivate() {
 }
 public void ejbPassivate() {
 }
 public void ejbLoad() {
 }
 public void ejbStore() {
 }
 public void ejbRemove() {
 }
}
----------------------------------------------------------------------------
-----------

----- Original Message -----
From: Tobias Streckel <[EMAIL PROTECTED]>
To: Orion-Interest <[EMAIL PROTECTED]>
Sent: Thursday, November 30, 2000 3:02 PM
Subject: Re: How can I use an BLOB datatype


Hello again,

my prog. is very easy. I'm only have a String (contain a big Text) and I
will it save on a colmn (Oracle DB) with a BLOB.

Thanks

Tobi

-----Ursprüngliche Nachricht-----
Von: Tim Endres <[EMAIL PROTECTED]>
An: Orion-Interest <[EMAIL PROTECTED]>
Datum: Donnerstag, 30. November 2000 07:10
Betreff: RE: How can I use an BLOB datatype


>Gernalizing this one step further. We have a situation where
>we want to place large ( larger than 10MB ) into the DB. Thus,
>when I get or store I would really like to have an InputStream
>or OutputStream to read or write the "object". However, it does
>not appear that EJB really supports this. Has anyone build an
>entity bean (or session for that matter) that can stream large
>amounts of data into and out of the database? How?
>
>Thanks,
>tim.
>
>> In CMP, the output streams should be created for you.
>> The database config xml file should provide a mapping
>> of a Serializable object to a BLOB/Image/etc.  If
>> this is done, the object will be serialized before
>> insertion automatically.
>>
>> -tim
>>
>
>







Reply via email to