|
|
Subject: RE: Binary data using Torque - msg#00006
List: jakarta.turbine.torque.user
Just curious... wouldn't you want to use a BLOB type for stuff like
this? Since it's variable and BINARY is fixed? Either way, both should
work.
One issue with both types is that you have to read the file into memory
to store it since both type are set via a Java byte[] objects. It might
be nice for blobs/clobs to support the java.sql.Blob/Clob interfaces in
some way. Not sure how to work this Torque's current Village
underpinning though, but I haven't dug into it at all.
FWIW, I've always found that putting pictures into a DB is generally
causes more performance problems than any benefits gained. Much easier
just to upload the file with a unique name to a resources directory and
then store the URL/reference info in the DB. But that's just a personal
view.
> -----Original Message-----
> From: Thomas Fischer [mailto:tfischer@xxxxxxxxxx]
>
> Yes, its possible. Postgresql has the bytea data type for
> storing binary
> data. Use the Torque type BINARY for it.
>
> Thomas
>
> On Wed, 26 Oct 2005, Jakub Piechnik wrote:
>
> > Hello
> >
> > I wonder if it's possible to handle binary data with Torque. I mean
> > that for
> > example there is a picture file (gif) and I want to put it
> in my database
> > (Postgresql). Is it possible to do that using Torque and if
> so - how should I
> > try to use it
> >
> > Regards
> > Jakub Piechnik
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: torque-user-unsubscribe@xxxxxxxxxxxxx
> > For additional commands, e-mail: torque-user-help@xxxxxxxxxxxxx
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@xxxxxxxxxxxxx
> For additional commands, e-mail: torque-user-help@xxxxxxxxxxxxx
>
>
Duke CE Privacy Statement
Please be advised that this e-mail and any files transmitted with it are
confidential communication or may otherwise be privileged or confidential and
are intended solely for the individual or entity to whom they are addressed.
If you are not the intended recipient you may not rely on the contents of this
email or any attachments, and we ask that you please not read, copy or
retransmit this communication, but reply to the sender and destroy the email,
its contents, and all copies thereof immediately. Any unauthorized
dissemination, distribution or copying of this communication is strictly
prohibited.
Was this page helpful?
Thread at a glance:
Previous Message by Date:
click to view message preview
RE: Question regarding Criterias
On Tue, 18 Oct 2005, Asaf Shakarchi wrote:
Hey,
Damn, why it's soooo complex to do such an easy task? :)
Why Criterion class doesn't have adjoin func? Then it would be possible
to create two Criterions and use 'or' function between them,
Patches are appreciated :-)
Well, here's my code anyway:
Criteria crit = new Criteria();
Criteria.Criterion linkFieldConnectorToField1 =
crit.getNewCriterion(FieldConnectorPeer.FIELD_ID1,FieldPeer.FIELD_ID,
Criteria.EQUAL);
Criteria.Criterion linkFieldConnectorToField2=
crit.getNewCriterion(FieldConnectorPeer.FIELD_ID2,FieldPeer.FIELD_ID,
Criteria.EQUAL);
Criteria.Criterion linkBothFieldConnectorToField =
linkFieldConnectorToField1.or(linkFieldConnectorToField2);
crit.add(linkBothFieldConnectorToField);
Well, this result a fine query but compare the fields to strings, I don't
understand, if the type of the field in the Criterions is PEER's field, why
the generated query doesn't set a condition of a field and assume it's a
text?
Sorry, I did not understand what the problem is. Can you please try to
explain again ?
Thanks a lot
Asaf.
Thomas
Next Message by Date:
click to view message preview
RE: Specifying the PK manually (Torque 3.1)
A quick thought on this is that there are also various DB
specific issues to deal with if the PK is defined as an
autoincrement field. For example, MS SQL won't let you do
an insert with an "Identity" field value unless you turn
off autoincrement on the table (remember to turn it back
on!). MySQL has the same behavious unless you to use
it's REPLACE operation.
Unfortunately, it's a case of autoincrement being a commonly
desired feature but not backed by a common standard. IMHO,
I'd say it's beyond the scope of Torque to try to create
it's own "autoincrement" standard that has to be supported/fit
into the various DB implimentations. It would be nice, but
a devil to maintain across new DB versions, etc.
> -----Original Message-----
> From: Thomas Fischer [mailto:tfischer@xxxxxxxxxx]
>
>
> Hi,
>
> From a simple point of view, the behavoiur you describe is
> not what one
> would want.
> However, I am of the opinion that this should not be changed in the
> forthcoming 3.2 release, because it would break backwards
> compatibility.
>
> Internally, doInsert calls the generated method
> BaseAuthorPeer.buildCriteria(), which
> inserts the Id only if the author is not new. The
> buildCriteria() method
> is also called from the doUpdate methods, and also in the
> Manager class,
> and cannot be changed easily. Of course, one can create Yet
> Another Method
> to accomplish this, making the classes even more complicated, which I
> would want to avoid.
>
> If you want, open a Bug report in scarab, it might be
> considered in a post
> 3.2 release (also depends on what the other deveolpers think about it)
>
> Thomas
>
> On Fri, 21 Oct 2005, Vitzethum, Daniel wrote:
>
> > Hello all,
> >
> > the following behavior just surprised me a bit: ;-)
> >
> > When creating a new instance of an OM object, setting the
> pk maually
> > and saving it, the PK will be ignored. If a id method is specified,
> > the pk will be retrieved from there (e.g. Oracle Sequence).
> >
> > When specifying the values via a Criteria object, I can set
> the PK and
> > it will be considered when saving. If the PK already exits, the DB
> > throws an error, certainly.
> >
> > Here's the example code:
> >
> > // when saving an author, pk is ignored
> > Author a1 = new Author();
> > a1.setAuthorId(999);
> > a1.setLastName("Knallinger");
> > a1.setFirstName("Ingnoratio");
> > AuthorPeer.doInsert(a1);
> >
> > // by criteria, pk will be used
> > Criteria c = new Criteria();
> > c.add(AuthorPeer.AUTHOR_ID, 999); c.add(AuthorPeer.LAST_NAME,
> > "Knüllinger"); c.add(AuthorPeer.FIRST_NAME, "Karl");
> > AuthorPeer.doInsert(c);
> >
> > Is this behavior considered to be correct (what is the background,
> > then), or not?
> >
> >
> > Daniel
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: torque-user-unsubscribe@xxxxxxxxxxxxx
> > For additional commands, e-mail: torque-user-help@xxxxxxxxxxxxx
> >
> >
>
Duke CE Privacy Statement
Please be advised that this e-mail and any files transmitted with it are
confidential communication or may otherwise be privileged or confidential and
are intended solely for the individual or entity to whom they are addressed.
If you are not the intended recipient you may not rely on the contents of this
email or any attachments, and we ask that you please not read, copy or
retransmit this communication, but reply to the sender and destroy the email,
its contents, and all copies thereof immediately. Any unauthorized
dissemination, distribution or copying of this communication is strictly
prohibited.
Previous Message by Thread:
click to view message preview
Re: Binary data using Torque
Yes, its possible. Postgresql has the bytea data type for storing binary
data. Use the Torque type BINARY for it.
Thomas
On Wed, 26 Oct 2005, Jakub Piechnik wrote:
Hello
I wonder if it's possible to handle binary data with Torque. I mean that for
example there is a picture file (gif) and I want to put it in my database
(Postgresql). Is it possible to do that using Torque and if so - how should I
try to use it
Regards
Jakub Piechnik
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@xxxxxxxxxxxxx
For additional commands, e-mail: torque-user-help@xxxxxxxxxxxxx
Next Message by Thread:
click to view message preview
RE: Binary data using Torque
"Greg Monroe" <Greg.Monroe@xxxxxxxxxx> schrieb am 01.11.2005 16:12:40:
> Just curious... wouldn't you want to use a BLOB type for stuff like
> this? Since it's variable and BINARY is fixed? Either way, both should
> work.
What do you mean with "Binary is fixed ?" I am no postgresql expert, but as
far as I know, bytea can store variable length data. And _IF_ blob is
mapped at all for postgresql, I would bet my head it is mapped to bytea as
well.
Maybe there are other databases where the Torque Type "BINARY" is mapped to
a data type which requires size specification, but Postgresql is not one of
them.
>
> One issue with both types is that you have to read the file into memory
> to store it since both type are set via a Java byte[] objects. It might
> be nice for blobs/clobs to support the java.sql.Blob/Clob interfaces in
> some way. Not sure how to work this Torque's current Village
> underpinning though, but I haven't dug into it at all.
Not so sure about that. From the point of view of a db abstraction layer,
in the ideal calse, all you want to do is save data into the db and read it
again, you do not want to use the internal logic needed to do that. So what
would be gained from havin the clob/blob handles available ? As I
understand it, the value about having handles would be to decide yourself
whether you read the data or not (this can bring performance gains as
blob/clob data is typically large). But this can also be achieved in
another way: Put the blob/clob data in another table which has a 1:1
relation to the original one, and read the extra table only if its needed.
>
> FWIW, I've always found that putting pictures into a DB is generally
> causes more performance problems than any benefits gained. Much easier
> just to upload the file with a unique name to a resources directory and
> then store the URL/reference info in the DB. But that's just a personal
> view.
>
Depends on whether you run your application in a cluster or not. On a
single server, the file system is fine. On a clustered system, syncing the
file systems is problematic in my experience.
> > -----Original Message-----
> > From: Thomas Fischer [mailto:tfischer@xxxxxxxxxx]
> >
> > Yes, its possible. Postgresql has the bytea data type for
> > storing binary
> > data. Use the Torque type BINARY for it.
> >
> > Thomas
> >
> > On Wed, 26 Oct 2005, Jakub Piechnik wrote:
> >
> > > Hello
> > >
> > > I wonder if it's possible to handle binary data with Torque. I mean
> > > that for
> > > example there is a picture file (gif) and I want to put it
> > in my database
> > > (Postgresql). Is it possible to do that using Torque and if
> > so - how should I
> > > try to use it
> > >
> > > Regards
> > > Jakub Piechnik
> > >
> > >
> > >
> > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: torque-user-unsubscribe@xxxxxxxxxxxxx
> > > For additional commands, e-mail: torque-user-help@xxxxxxxxxxxxx
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: torque-user-unsubscribe@xxxxxxxxxxxxx
> > For additional commands, e-mail: torque-user-help@xxxxxxxxxxxxx
> >
> >
>
> Duke CE Privacy Statement
> Please be advised that this e-mail and any files transmitted with it
> are confidential communication or may otherwise be privileged or
> confidential and are intended solely for the individual or entity to
> whom they are addressed. If you are not the intended recipient you
> may not rely on the contents of this email or any attachments, and
> we ask that you please not read, copy or retransmit this
> communication, but reply to the sender and destroy the email, its
> contents, and all copies thereof immediately. Any unauthorized
> dissemination, distribution or copying of this communication is
> strictly prohibited.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@xxxxxxxxxxxxx
> For additional commands, e-mail: torque-user-help@xxxxxxxxxxxxx
>
|
|