Guest User

Untitled

a guest
Sep 14th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. JRuby ActiveRecord/ActiveModel not creating methods and attributes for table columns (undefined method)
  2. create_table "THE_CONFIGURATION", :primary_key => "CONFIGURATION_ID", :force => true do |t|
  3. t.string "CONFIGURATION_GROUP", :limit => 32
  4. t.string "CONFIGURATION_TYPE", :limit => 32
  5. t.string "CONFIGURATION_NAME", :limit => 32
  6. t.string "CONFIGURATION_TEXT", :limit => 7168
  7. end
  8.  
  9. create_table "THE_CONFIGURATION", :primary_key => "CONFIGURATION_ID", :force => true do |t|
  10. t.string "CONFIGURATION_GROUP", :limit => 32
  11. t.string "CONFIGURATION_TYPE", :limit => 32
  12. t.string "CONFIGURATION_NAME", :limit => 32
  13. t.string "CONFIGURATION_TEXT", :limit => 7168
  14. end
  15.  
  16. require 'rubygems'
  17. require 'active_record'
  18.  
  19. class Configuration < ActiveRecord::Base
  20. self.table_name = 'SOART_CONFIGURATION'
  21. self.primary_key = 'configuration_id'
  22. end
  23.  
  24. require 'java'
  25. require 'rubygems'
  26. require 'active_record'
  27.  
  28. class ConnectionMaster
  29. def test_object
  30. "ARBITRARY"
  31. end
  32.  
  33. def set_connection
  34. ActiveRecord::Base.establish_connection(
  35. :adapter => 'jdbc' ,
  36. :driver => 'com.sybase.jdbc4.jdbc.SybDriver' ,
  37. :url => 'jdbc:sybase:Tds:192.168.137.137:1111/MYAPP' ,
  38. :username => 'noneya' ,
  39. :password => 'noneya'
  40. )
  41. ActiveRecord::Base.connection.execute("SELECT 'ARBITRARY' AS ARBITRARY")
  42. end
  43.  
  44. def clear_connections
  45. ActiveRecord::Base.clear_active_connections!
  46. end
  47.  
  48. end
  49.  
  50. public void testRubyDatabaseQuery() {
  51. String theValue = "test";
  52. String jrubyCode =
  53. "require 'connection_master' n"
  54. + "require 'configuration' n"
  55. + "cm = ConnectionMaster.new n"
  56. + "cm.set_connection n"
  57. + "puts 'black cow of revenge' n"
  58. + "config = Configuration.find(:all,:conditions => ['configuration_name=?','test']) n"
  59. + "config = Configuration.find_by_configuration_name('test') n"
  60. + "puts 'red cow of revenge' n"
  61. + "cm.clear_connections n"
  62. + "config.configuration_text n";
  63. String executeValue = (String)JRubyMaster.execute(jrubyCode);
  64. this.assertEquals("executeValue and theValue do not match.", theValue, executeValue);
  65. }
Add Comment
Please, Sign In to add comment