Skip to content

Commit

Permalink
cleanups, now we can pass ENV variables in order to turn on/off SQL l…
Browse files Browse the repository at this point in the history
…ogging
  • Loading branch information
Piotr Gęga committed Oct 1, 2011
1 parent 3d0e6df commit b168d05
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/dm-hibernate-adapter.rb
Expand Up @@ -74,8 +74,8 @@ def initialize(name, options = {})

Hibernate.properties["cache.provider_class"] = "org.hibernate.cache.NoCacheProvider"
Hibernate.properties["hbm2ddl.auto"] = "update"
Hibernate.properties["format_sql"] = "false"
Hibernate.properties["show_sql"] = "true"
Hibernate.properties["format_sql"] = ENV['FORMAT_SQL'] == 'true' ? 'true' : 'false'
Hibernate.properties["show_sql"] = ENV['SHOW_SQL'] == 'true' ? 'true' : 'false'

end

Expand Down
12 changes: 6 additions & 6 deletions lib/dm-hibernate-adapter/hibernate.rb
Expand Up @@ -88,7 +88,7 @@ def ensure_hibernate_key(key)
end

def self.properties
PropertyShim.new(@config)
@@property_shim ||= PropertyShim.new(@@config)
end

def self.tx(&block)
Expand All @@ -112,24 +112,24 @@ def self.tx(&block)
end

def self.factory
@factory ||= config.build_session_factory
@@factory ||= config.build_session_factory
end

def self.session
factory.open_session
end

def self.reset_config
if @config
if @@config
# TODO make the whole with a list of property names
# define the static accessors with the very same list
dialect = self.dialect
username = self.connection_username
password = self.connection_password
url = self.connection_url
driver_class = self.connection_driver_class
@factory = nil
@config = AnnotationConfiguration.new
@@factory = nil
@@config = AnnotationConfiguration.new
self.dialect= dialect
self.connection_username = username
self.connection_password = password
Expand All @@ -139,7 +139,7 @@ def self.reset_config
end

def self.config
@config ||= AnnotationConfiguration.new
@@config ||= AnnotationConfiguration.new
end

def self.add_model(model_java_class, name)
Expand Down

0 comments on commit b168d05

Please sign in to comment.