Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spec: self referecing and direct sql #18

Closed
douglasrodrigo opened this issue Oct 4, 2011 · 24 comments
Closed

spec: self referecing and direct sql #18

douglasrodrigo opened this issue Oct 4, 2011 · 24 comments

Comments

@douglasrodrigo
Copy link
Collaborator

Executing adapter spec I got a error, but creating the same Friend resource on the irb I got things working:

executing with irb:

system :005 > Friend.first.creator
Friend.first.creator
Hibernate:
select
this_.id as id2_0_,
this_.creator_id as creator2_2_0_,
this_.name as name2_0_
from
friends this_
where
(
this_.id=?
) limit ?

=> #<Friend @id=1 @name="god" @creator_id=1>

Adapter spec:

[INFO] 1)
[INFO] NativeException in 'DataMapper::Adapters::HibernateAdapter self referecing and direct sql should create a self referencing enitity'
[INFO] org.hibernate.PropertyAccessException: Exception occurred inside setter of rubyobj.Friend.creator_id
[INFO] org/hibernate/property/BasicPropertyAccessor.java:89:in set' [INFO] org/hibernate/tuple/entity/AbstractEntityTuplizer.java:352:insetPropertyValues'
[INFO] org/hibernate/tuple/entity/PojoEntityTuplizer.java:232:in setPropertyValues' [INFO] org/hibernate/persister/entity/AbstractEntityPersister.java:3580:insetPropertyValues'
[INFO] org/hibernate/engine/TwoPhaseLoad.java:152:in initializeEntity' [INFO] org/hibernate/loader/Loader.java:877:ininitializeEntitiesAndCollections'
[INFO] org/hibernate/loader/Loader.java:752:in doQuery' [INFO] org/hibernate/loader/Loader.java:259:indoQueryAndInitializeNonLazyCollections'
[INFO] org/hibernate/loader/Loader.java:2232:in doList' [INFO] org/hibernate/loader/Loader.java:2129:inlistIgnoreQueryCache'
[INFO] org/hibernate/loader/Loader.java:2124:in list' [INFO] org/hibernate/loader/criteria/CriteriaLoader.java:118:inlist'
[INFO] org/hibernate/impl/SessionImpl.java:1597:in list' [INFO] org/hibernate/impl/CriteriaImpl.java:306:inlist'
[INFO] org/hibernate/property/BasicPropertyAccessor.java:89:in set' [INFO] org/hibernate/tuple/entity/AbstractEntityTuplizer.java:352:insetPropertyValues'
[INFO] org/hibernate/tuple/entity/PojoEntityTuplizer.java:232:in setPropertyValues' [INFO] org/hibernate/persister/entity/AbstractEntityPersister.java:3580:insetPropertyValues'
[INFO] org/hibernate/engine/TwoPhaseLoad.java:152:in initializeEntity' [INFO] org/hibernate/loader/Loader.java:877:ininitializeEntitiesAndCollections'
[INFO] org/hibernate/loader/Loader.java:752:in doQuery' [INFO] org/hibernate/loader/Loader.java:259:indoQueryAndInitializeNonLazyCollections'
[INFO] org/hibernate/loader/Loader.java:2232:in doList' [INFO] org/hibernate/loader/Loader.java:2129:inlistIgnoreQueryCache'
[INFO] org/hibernate/loader/Loader.java:2124:in list' [INFO] org/hibernate/loader/criteria/CriteriaLoader.java:118:inlist'
[INFO] org/hibernate/impl/SessionImpl.java:1597:in list' [INFO] org/hibernate/impl/CriteriaImpl.java:306:inlist'
[INFO] /home/douglas/projetos/jibernate-dm/lib/dm-hibernate-adapter.rb:176:in `read'

@mkristian
Copy link
Owner

is this solved now ? since the adapter specs are passing now.
was/is the issue related to the reloading of ruby classes (just wild guess)?

@douglasrodrigo
Copy link
Collaborator Author

after the refactoring, the specs are all green.

@pietia
Copy link
Collaborator

pietia commented Oct 17, 2011

@mkristian, i don't think it's solved, we just run tests against original 'abstract adapter' now . Previously that was 'abstract adapter' with some additional specs copied over from other dm-core specs. I think that's why we are now green. But that's only partially true, we are green for: Mysql, Postgres, h2. Derby and Hsql are still work in progress.

@pietia
Copy link
Collaborator

pietia commented Oct 17, 2011

@douglasrodrigo , i think we can keep this ticket closed. On the other hand it would be great to have possibility to run dm-core specs with our adapter.

AFAIR in order to run dm-core specs with, let's say, postgres we have to just set proper ADAPTER var:

cd dm-core
rvm use jruby
ADAPTERS=postgres rake spec

My question is if that ^ will play nice with ruby-maven and our adapter?

More info here: https://github.com/datamapper/do/wiki/jruby

@mkristian
Copy link
Owner

I will have a look and make it work with ruby-maven. the rvm use jruby is probably not needed.

another question is where the dm-hibernate code is coming from, i.e. it might need to add it into the Gemfile as well. let's see.

@douglasrodrigo
Copy link
Collaborator Author

Ok, I will try reproduce with older specs version just to see if is still broken.

@pietia
Copy link
Collaborator

pietia commented Oct 17, 2011

@douglasrodrigo please stop :) we don't need this now. Let's wait for possibility to run real dm-core specs. Then we will have a lot of fixing to do ;)

@douglasrodrigo
Copy link
Collaborator Author

ok, it's a good idea.

@mkristian
Copy link
Owner

https://gist.github.com/1292550

still running the in-memory specs but that could work ;-)

the Gemfile I changed the source for the plugins like dm-migration - i.e. just take the gem from rubygems. simliar for the dm adapters as well. and I needed to add the dm-hibernate-gem at the end.

@mkristian
Copy link
Owner

not sure if that runs the right adapter but all the jars are in the classpath.

@pietia
Copy link
Collaborator

pietia commented Oct 17, 2011

will take a look a little bit later (daily job)

@douglasrodrigo
Copy link
Collaborator Author

Kristian, so many specs broken????

We can create a integration test environment of the adapter running dm specs in the cloudbees.

@mkristian
Copy link
Owner

$ ADAPTER=hibernate rake spec
1 [ScriptThreadProcess: -Ilib:lib:spec] INFO org.hibernate.cfg.annotations.Version - Hibernate Annotations 3.4.0.GA

things are shaping but you need to add a Mavenfile and use the singular ADAPTER env

@mkristian
Copy link
Owner

first I see duplicate class definitions, so we need to use the reload mode of the adapter to run the test and how to configure the whole thing I do not know

@mkristian
Copy link
Owner

with cloudbees - yes sound good, actually the jruby-maven-plugins also run there though I did not set it up myself. but maybe we wait until we have some passing specs ;-)

@pietia
Copy link
Collaborator

pietia commented Oct 17, 2011

I'm having some problems with installing git gem. Any workaround?

@douglasrodrigo
Copy link
Collaborator Author

Same problem here.

http://rubygems-proxy.torquebox.org/releases/rubygems/git/1.2.5/git-1.2.5.pom

Acessing on browser show an exception.

@douglasrodrigo
Copy link
Collaborator Author

My steps:

  • merge master to reload branch
  • put a fake git.pom (the git gem is broken on maven rubygems repository) on my local repository :)
  • get back /lib/dm-hibernate-adapter/spec/setup.rb

my console log:

https://gist.github.com/1294400

@mkristian
Copy link
Owner

I was I day offline and have to find out that you guys had again a problem I had not. maybe fixing the git gem version to '1.1.0' might help too.

@pietia
Copy link
Collaborator

pietia commented Oct 20, 2011

I had to do some hacks with fake git.pom in order to run specs. Had
reloading problems. ...

@mkristian
Copy link
Owner

in spec/dm_core/spec_helper.rb was (it is gone now): Hibernate.reset_config

which just resets the Hibernate config completely which is used in case of "conflict" when :allow_reload is configured on the adapter. I will play around with the specs this evening ;-)

@pietia
Copy link
Collaborator

pietia commented Oct 21, 2011

Ok, please add Hibernate.reset_config then :). I added yesterday ENV
variable to set :reload option.

@mkristian
Copy link
Owner

I am trying hard to get my TODO list small again. so it was busy week for me, hope next week I will find time for dm-hibernate again.

@pietia
Copy link
Collaborator

pietia commented Oct 27, 2011

I'm busy too :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants