Re: arbitrary SQL

2004-11-11 Thread Anthony E. Carlos
Thanks for the help, Robert and Gerhard!
I'm pleasantly shocked at how timely your responses were. I wish this 
was in the FAQs because it's implied that only queries that return 
something can be done using QueryBySQL. I guess we're doing an 
end-around with this new code.

I must confess also, that I slept through the class on using the 
java.sql package (just kidding, I haven't been to school in 10 years)-- 
up until now, we've been using just OJB and it's O/R has handled 
everything. So, I guess that's a good thing that I haven't needed the 
lower level interfaces.

Thanks again,
-Anthony
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


arbitrary SQL

2004-11-11 Thread Anthony E. Carlos
Hello,
How do I fire off a an arbitrary SQL statement that doesn't require a 
return value?

For example, (I already know how to do this using O/R mapping-- this is 
just a simple example)

INSERT INTO colors VALUES ('red');
I've looked at the FAQs, but the only example is for SELECT statements, 
which obviously return values.

I've tried using
String sql = "INSERT INTO colors (color) VALUES ('red')";
Query query = QueryFactory.newQuery(ColorVO.class, sql);
I was using
broker.getObjectByQuery(query);
but it complains that I have an invalid column. The problem is, why do 
I need "ColorVO.class" at all?

I've also tried
broker.getReportQueryIteratorByQuery(query);
and it complains that I have an invalid SQL statement.
So, is there any way to fire off arbitrary SQL without a return value?
Thanks,
-Anthony
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Mapping inheritance hierarchies

2004-09-02 Thread Anthony E. Carlos
Hello all,
Here's a question about mapping inheritance hierarchies. Yes, I've read  
http://db.apache.org/ojb/docu/guides/advanced- 
technique.html#Mapping+Classes+on+Multiple+Joined+Tables. Let's say I  
have a base class A, and classes B and C which both extend A. I am  
mapping classes on multiple joined tables, and have set auto-update to  
true. OJB is working great when I insert/update B or C classes and is  
properly populating table A plus B or C. However, if I want to save a C  
class with the same primary key as an existing B class (effectively  
giving an instance of B some qualities of C), OJB is trying to insert a  
record into A and I get a unique key constraint violation since the  
primary key already exists. I was wondering why OJB was trying to do an  
insert even though I've already specified a primary key.

I tried the hint in  
http://db.apache.org/ojb/docu/tutorials/pb- 
tutorial.html#Updating+Persistent+Objects to force an update (which  
didn't change anything):

// alternative, more performant
// broker.store(result, ObjectModificationDefaultImpl.UPDATE);
This leads me to believe that I may have a wrong assumption in design.  
Perhaps B and C cannot share the same A? How would you map it? Is there  
a better pattern to follow?

Thanks,
-Anthony Carlos
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Conditional auto-update/best practices

2003-10-28 Thread Anthony E. Carlos
Hello,

I've tried searching the archives for a solution to what should be a
common problem. Sometimes I want to persist an object graph that maps
to multiple tables in my database. OJB handles it beautifully when I
set it the reference-descriptor's auto-update attribute to "true".
However, there are times when I only want to update the main table. I
get into problems when I try to persist the object without the related
objects because I usually get a CANNOT INSERT A NULL error in the
related tables.
Therefore, my question is, can you set the auto-update conditionally?
Or am i REQUIRED to create all the related objects even if I only want
to save the main object?
I'm also wondering if I just am on the wrong track. After reading
"Professional Struts Applications" (Wrox), a particular line is hinting
that maybe I'm missing something. They say, "A Value Object is nothing
more than a view of the data and there is nothing inappropriate about
having a DAO return different types of Value Objects, all showing a
different perspective of the same piece of data." This seems to hint
that perhaps I should create a separate Value Object (with its own
metadata in repository_user.xml) for when I want to persist an object
without its related objects. This seems messy because it increases
maintenance if the object definition changes (I'll have to change it in
more than one place). Is this the standard, or best practice? What is
everyone else doing?
Thanks,

Anthony Carlos

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


newbie question

2003-08-04 Thread Anthony E. Carlos
Hello all,

I'm using the PB API and can store a simple object to a table. Even 
though table has a primary key constraint on the id column, if I try to 
store a different object with the same id, there is no primary key 
constraint violation. In fact, OJB _UPDATES_ the existing matching row 
in the database, instead of trying to INSERT a new row (which would 
trigger the integrity constraint). I'm using Oracle 8i.

My question, therefore, is:

Do I have to perform my own referential integrity checks when I use 
OJB? Am I missing a basic idea behind OJB (like the lack of a need for 
referential integrity)?

I've searched the mail archives and the online docs, but can't find the 
answer to these simple questions.

Thanks,

Anthony Carlos

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]