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
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
look at the db sure enough it hasn’t changed. I’m running
Has anyone any idea why this might be or how I can check to see if my
connection has autocommit enabled from within jruby?
:adapter => “jdbc”,
:driver => ‘oracle.jdbc.driver.OracleDriver’,
:url => “jdbc:oracle:thin:@mydbservver:1521:mydb”,
:username => “my_username”,
:password => “my_pass”)
class Alert < ActiveRecord::Base
alert_id <=> other.alert_id
“Alert Id:=” + alert_id.to_s + ", parent_id := " + parent_id.to_s +
", message := " + message.to_s
if FILE == $0
alert = Alert.find(312)
alert.notified = ‘Y’
if alert.save == false then
raise “Error Message”
alert2 = Alert.find(312)
Here’s the DDL for the table, sequence and trigger
create table ALERTS (
alert_id number PRIMARY KEY ,
creation date NOT NULL,
message varchar(100) NOT NULL,
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’ )) ,
FOREIGN KEY (parent_id)
create sequence ALERT_SEQ
start with 1
increment by 1
CREATE OR REPLACE TRIGGER STAGING_OWNER.ALERT_TRIGGER
BEFORE INSERT ON STAGING_OWNER.ALERTS
FOR EACH ROW
select ALERT_SEQ.nextval into :new.alert_id from dual;
On 6/13/07, Mark G. [email protected] wrote:
if alert.save == false then
raise "Error Message"
No need for that construct; the save! method will raise an error if
the save fails. Replace the above with:
I’ve since successfully performed the jruby ActiveRecord-JDBC found
using the exact same connection specifications as in my example and it
fine. Tables are on the same database and everything so I think I can
that it’s an oracle problem. Is that presumptuous?
I can perform updates to my alerts table by getting hte connection and
the update method with some SQL but this isn’t the way I was hoping to
Any ideas folks?
Had to resort to querying the V$SQL statements at the oracle
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,
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 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?