Hey folks,
I''ve a very simple ruby file as described as provided below.
When I run the file the indication I get back from the .save method is
that
the notified attribute change has been saved and yet when I retrieve the
row again straight away after the notified value hasn''t changed and
when
I
look at the db sure enough it hasn''t changed. I''m running
jruby RC3
ActiveRecord-JDBC 0.3.2
activerecord-1.15.3
activesupport-1.4.2
Has anyone any idea why this might be or how I can check to see if my
connection has autocommit enabled from within jruby?
Thanks
Mark.
require ''java''
require ''rubygems''
gem ''ActiveRecord-JDBC''
require ''jdbc_adapter''
require ''active_record''
ActiveRecord::Base.establish_connection(
:adapter => "jdbc",
:driver => ''oracle.jdbc.driver.OracleDriver'',
:url => "jdbc:oracle:thin:@mydbservver:1521:mydb",
:username => "my_username",
:password => "my_pass")
class Alert < ActiveRecord::Base
set_primary_key "ALERT_ID"
def <=>(other)
alert_id <=> other.alert_id
end
def to_s
"Alert Id:=" + alert_id.to_s + ", parent_id := " +
parent_id.to_s +
", message := " + message.to_s
end
end
if __FILE__ == $0
alert = Alert.find(312)
alert.notified = ''Y''
puts alert
if alert.save == false then
raise "Error Message"
end
alert2 = Alert.find(312)
puts alert2.notified
end
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Here''s the DDL for the table, sequence and trigger
--Table
create table ALERTS (
alert_id number PRIMARY KEY ,
parent_id number,
creation date NOT NULL,
message varchar(100) NOT NULL,
throwable varchar(3000),
severity_id number CHECK ( severity_id IN (10000, 20000, 30000,
40000, 50000)) NOT NULL,
severity_status varchar(20) CHECK (severity_status IN
(''DEBUG'',
''INFO'', ''WARN'', ''ERROR'',
''FATAL'')) NOT NULL,
notified CHAR(1) DEFAULT (''N'') CHECK (notified IN (
''Y'', ''N'' )) ,
trace_user varchar(20),
trace_session varchar(50),
CONSTRAINT fk_alert
FOREIGN KEY (parent_id)
REFERENCES alerts(alert_id)
);
--Sequence
create sequence ALERT_SEQ
start with 1
increment by 1
nomaxvalue;
-- Trigger
CREATE OR REPLACE TRIGGER STAGING_OWNER.ALERT_TRIGGER
BEFORE INSERT ON STAGING_OWNER.ALERTS
FOR EACH ROW
begin
select ALERT_SEQ.nextval into :new.alert_id from dual;
end;
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
On 6/13/07, Mark Gargan <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> if alert.save == false then > raise "Error Message" > endNo need for that construct; the save! method will raise an error if the save fails. Replace the above with: alert.save! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hey Bob,
Thanks for getting back to me.
I tried that earlier but to no avail. I still get the same result.
Any idea how i find if autocommit is on via the connection in jruby?
Thanks,
Mark.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
I''ve since successfully performed the jruby ActiveRecord-JDBC found here. http://www.ociweb.com/mark/programming/ActiveRecord.html using the exact same connection specifications as in my example and it works fine. Tables are on the same database and everything so I think I can rule out that it''s an oracle problem. Is that presumptuous? I can perform updates to my alerts table by getting hte connection and calling the update method with some SQL but this isn''t the way I was hoping to develop it. Any ideas folks? Thanks, Mark -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
The folks,
Had to resort to querying the V$SQL statements at the oracle
DB.
Does anyone know how to output the SQL generated by ActiveRecord-JDBC?
Would''ve made life a little easier.
Anyways it turns out the problem was in the line in my Alert model,
set_primary_key "ALERT_ID"
ALERT_ID is indeed the primary key of the table, however,
the attribute name in the Alert object is lowercase, alert_id.
Because of that update sql was being appended with
''WHERE ALERT_ID is NULL'' sure enough none of the records
have and alert_id of null as its the primary key.
Thanks,
Mark.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---