Closed sweetguy0883 closed 11 years ago
The automapping is registering the CouchDocument
subnamespace of your bundle, not Document
(which is auto-mapped by DoctrineMongoDBBundle)
Hi, Thanks for the reply. I am not still clear. Are you talking about the /* @Document /
in the Testing.php class in the MyApp\MyBundle\Document folder ? Or something else? Some more hints please. @stof .
Hi, Thanks. Got it. Renamed my Document folder to CouchdbDocument and all the files where the link was used. But still I am unable to enter the value for the _id in the database. Also, a new field is being created named as "type" with the value "MyApp.MyBundle.CouchDocument.Testing"
. Any suggestions for it?
type
is a property used by the CouchDB ODM internally to know which class should be used to map the struct to a PHP object: https://github.com/doctrine/couchdb-odm/blob/master/lib/Doctrine/ODM/CouchDB/Mapping/MetadataResolver/DoctrineResolver.php#L32
Hello, I had removed all the couchdb odm and the bundle from my project and installed them by composer. The previous links I found was not working but at last the links from the PackageList worked and so I went for the composer option. Now the problem has again raised. When I use
$repository = $dm->getRepository("MyApp\MyBundle\CouchDocument\User")->find($user);
It gives an error message as:
The class 'Visalyze\AdminBundle\CouchDocument\User' was not found in the chain configured namespaces
500 Internal Server Error - MappingException
Also it says there is problem in
symfonyApp/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/MappingException.php at line 38
Why is it looking in the Common Persistance Mapping? isn't it supposed to be
symfonyApp/vendor/doctrine/couchdb-odm/lib/Doctrine/ODM/CouchDB/Mapping/MappingException.php
And if I use
$repository = $dm->getRepository("User")->find($user);
then it says
The class: User could not be found
500 Internal Server Error - MappingException
But this time the error comes from
symfonyApp/vendor/doctrine/couchdb-odm/lib/Doctrine/ODM/CouchDB/Mapping/MappingException.php at line 18
My enitity class files are in MyApp/MyBundle/CouchDocument/ . Please help... I am stuck and finding no way to come out of it.. @stof
I've find the solution here >>> http://stackoverflow.com/questions/23701144/configuring-symfony-doctrinecouchdbbundle
And it works. You must add in ODM a mapping to your bundle.
Hello @misteio Thanks for the input. The link you provided does not relate my problem. I solved it a long ago. That link was taking about a single database and in my case, I had many different databases. For others who might be interested in this problem, if I remember correctly, I solved it just by setting the auto_mapping: false in the database configuration
Hi @sweetguy0883 . I 'm beginner in symfony. I 'm using symfony with mongo db . But I'm getting this error still. Please help me ! My app/config.yml ; doctrine_mongodb: connections: default: server: mongodb://localhost:27017 options: {} default_database: test_database document_managers: default: auto_mapping: true
Controller ; $product = new Product(); $product->setName("Erdem"); $product->setAge('25'); $product->setSchool("Sakarya Üniversitesi");
$dm = $this->get('doctrine_mongodb')->getManager();
$dm->persist($product);
$dm->flush();
return new Response('Created product id '.$product->getId());
Hello @erdemildiz . Thanks for your message. Though this was a topic with couchDb, I think this is a general problem. But can you please give a bit more details like the namespace of the files and the exact error message. Also please don't forget to check the spacing in the yml files and most importantly (the silliest one but I do it quite often) make sure that the mongoDb is running...
mongoDb is running. But same error.
app/config.yml
doctrine_mongodb: connections: default: server: mongodb://localhost:27017 options: {} default_database: test_database document_managers: default: auto_mapping: false
Controller
namespace fuar\sergiBundle\Controller;
use fuar\sergiBundle\Entity\Product; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Response;
class DefaultController extends Controller { public function indexAction() { $product = new Product(); $product->setName("xxx"); $product->setAge('25'); $product->setSchool("xxxx");
$dm = $this->get('doctrine_mongodb')->getManager();
$dm->persist($product);
$dm->flush();
return new Response('Created product id '.$product->getId());
}
}
fuar/sergiBundle/Entity/Product.php
namespace fuar\sergiBundle\Entity;
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
/**
Product / class Product { /*
/**
2014-11-21 11:40 GMT+02:00 sweetguy0883 notifications@github.com:
Hello @erdemildiz https://github.com/erdemildiz . Thanks for your message. Though this was a topic with couchDb, I think this is a general problem. But can you please give a bit more details like the namespace of the files. Also please don't forget to check the spacing in the yml files and most importantly (the silliest one but I do it quite often) make sure that the mongoDb is running...
— Reply to this email directly or view it on GitHub https://github.com/doctrine/DoctrineCouchDBBundle/issues/26#issuecomment-63946645 .
Did you install via composer as in http://symfony.com/doc/current/bundles/DoctrineMongoDBBundle/index.html ?
Then you have to put your mapping files in Document folder and not in the Entity folder. This folder naming made me cry a few days. Also. when you have single database, it is better to have auto_mapping to be true.
Yes . it install with composer and changing auto_mapping :true. :( Same error again
2014-11-21 11:49 GMT+02:00 sweetguy0883 notifications@github.com:
Did you install via composer as in http://symfony.com/doc/current/bundles/DoctrineMongoDBBundle/index.html ?
Then you have to put your mapping files in Document folder and not in the Entity folder. This folder naming made me cry a few days. Also. when you have single database, it is better to have auto_mapping to be true.
— Reply to this email directly or view it on GitHub https://github.com/doctrine/DoctrineCouchDBBundle/issues/26#issuecomment-63947662 .
I follow the instructions in http://symfony.com/doc/current/bundles/DoctrineMongoDBBundle/index.html . But this error
2014-11-21 11:52 GMT+02:00 erdem ıldız erdemildiz@gmail.com:
Yes . it install with composer and changing auto_mapping :true. :( Same error again
2014-11-21 11:49 GMT+02:00 sweetguy0883 notifications@github.com:
Did you install via composer as in http://symfony.com/doc/current/bundles/DoctrineMongoDBBundle/index.html ?
Then you have to put your mapping files in Document folder and not in the Entity folder. This folder naming made me cry a few days. Also. when you have single database, it is better to have auto_mapping to be true.
— Reply to this email directly or view it on GitHub https://github.com/doctrine/DoctrineCouchDBBundle/issues/26#issuecomment-63947662 .
Did you rename the folder where the mapping files (Product.php) resides? If not then please rename the "Entity" folder to be "Document". They have some problem with specific naming.... also don't forget to clear the cache from the console and the browser cache too.
Where is this folder . Idont find it. Web error is this;
2014-11-21 12:05 GMT+02:00 sweetguy0883 notifications@github.com:
Did you rename the folder where the mapping files (Product.php) resides? If not then please rename the "Entity" folder to be "Document". They have some problem with specific naming.... also don't forget to clear the cache from the console and the browser cache too.
— Reply to this email directly or view it on GitHub https://github.com/doctrine/DoctrineCouchDBBundle/issues/26#issuecomment-63949582 .
I can't see your error...
The folder is inside your bundle, check in your controller, where you define your class to be (fuar\sergiBundle\Entity) but this class should be in (fuar\sergiBundle\Document)
Also check your Product class properly. You define things as "@var integer" or "@var string" but check the documentation properly... it says "@MongoDB\Id" or "@MongoDB\String". And the class should be defined as "@MongoDB\Document" and not the class name ("Product" as you have defined). This declarations are very important and without this the mapping of the database cannot work.
FIRST ERROR
erdemildiz@ERDEMILDIZ /C/xampp/htdocs/symfony $ php app/console cache:clear --env=prod Clearing the cache for the prod environment with debug false
[Doctrine\Common\Persistence\Mapping\MappingException] Class 'fuar\sergiBundle\Entity\Product' does not exist
cache:clear [--no-warmup] [--no-optional-warmers]
I DIDNT FINT "Doctrine\Common\Persistence\Mapping\MappingExceptio"
SECOND ERROR
Class fuar\sergiBundle\Document\Product is not a valid document or mapped super class. 500 Internal Server Error - MappingException
PLEASE HELP ME
2014-11-21 12:38 GMT+02:00 sweetguy0883 notifications@github.com:
I can't see your error...
The folder is inside your bundle, check in your controller, where you define your class to be (fuar\sergiBundle\Entity) but this class should be in (fuar\sergiBundle\Document)
Also check your Product class properly. You define things as "@var https://github.com/var integer" or "@var https://github.com/var string" but check the documentation properly... it says "@MongoDB https://github.com/MongoDB\Id" or "@MongoDB https://github.com/MongoDB \String". And the class should be defined as "@MongoDB https://github.com/MongoDB\Document" and not the class name ("Product" as you have defined). This declarations are very important and without this the mapping of the database cannot work.
— Reply to this email directly or view it on GitHub https://github.com/doctrine/DoctrineCouchDBBundle/issues/26#issuecomment-63953522 .
$ php app/console cache:clear --env=prod --no-debug
$ php app/console cache:clear
Also check your Product class properly. You define things as "@var integer" or "@var string" but check the documentation properly... it says "@MongoDB\Id" or "@MongoDB\String".
And the class should be defined as "@MongoDB\Document" and not the class name ("Product" as you have defined). This declarations are very important and without this the mapping of the database cannot work.
You are defining the mapping as referred by MongoDb but you are not following its specific rules... You must keep an eye on this.
Hi, I have exactly the same problem with mongodb No Entity folder, only Document one I use correct syntax for class declaration But still the same problem... (symfony 2 mongodb)
http://stackoverflow.com/questions/27299657/mongodb-class-document-not-exist-symfony-2
@sweetguy0883 please adivises how you solve it... cause I have set 'auto_mapping: false' in a config but it still not working for me:
$cat = $dm->getRepository("MyBundle\CouchDocument\PlaceCategory")->find($catId);
the error: The class 'MyBundle\CouchDocument\PlaceCategory' was not found in the chain configured namespaces
@diderson Make sure about a few things and please write it here.
@42aroger Sorry for my late reply. Could you solve your problem? I somehow overlooked your comment. Are you sure you are using monogodb-odm-bundle and not mongodb-odm? The stackoverflow code, it looks to be working.
@stiffroy I am using couchdb-odm-bundle
but both are installed: (couchdb-odm and couchdb-odm-bundle
actually I did manage to get this working by changing my config file to:
doctrine_couch_db:
client:
dbname: mydbname
host: localhost
port: 5984
user: null
password: null
ip: null
logging: false
odm:
document_managers:
default:
mappings:
myBundle:
type: annotation
auto_mapping: false
Hello, I am trying to use this bundle with Symfony2 version 2.2 system working for last few days but no luck. My database configuration is (I am using multiple databases) :
My document class is :
And my controller is :
But my problem is, the code is working fine until I am using the
$dm->persist($testing);
function. But as soon as I am using it, the browser throws an error :But if I am making the connection a way around (as described in Dortrine CouchDB Documentation)
everything is running well. But I like the method described in this bundle as it looks neat and clean with less codes. Is there something I am missing or is it the problem with the 2.2 version. Please help.