Viewed   86 times

Is it possible to generate a single entity from database using the Symfony2 console tool?

In the middle of coding I had to add a table and there are modifications made to the existing entity classes. So I don't want all my entities regenerated.

Any suggestions will be appreciated!



I had the same problem, you've to do this way:

php app/console doctrine:mapping:convert metadata_format 


php app/console doctrine:mapping:import AppMyBundle 
    metadata_format --filter="Yourtablename"

Where metadata_format is the file ending you want to generate (e.g. xml, yml, annotation)

And finally

php app/console doctrine:generate:entities AppMyBundle --no-backup

Like this doctrine will load only the entity you need. Just be carefull on the filter you must use the CamelCase !

Hope this will help you

Sunday, August 21, 2022

I donno why/how but it works

here's the code :

    auto_generate_proxy_classes: "%kernel.debug%"
            naming_strategy: doctrine.orm.naming_strategy.underscore
            auto_mapping: true
            naming_strategy: doctrine.orm.naming_strategy.underscore
            connection: crawl
                DbBccCrawlBundle: ~

the thing is that I tried that at the start and it failed (the class X not found in...)

If anyone has an explenation, I'll be more than happy to read it.

Thanks anyway

This was the 2nd part of the question, here's the begening : The class 'X' was not found in the chain configured namespaces ... when I try a multiple connection with doctrine

Friday, August 12, 2022

If I get you correctly, you want to import your existing database?

What I do is:

php app/console doctrine:mapping:convert xml ./src/App/MyBundle/Resources/config/doctrine/metadata/orm --from-database --force

Then do a selective convert to annotation:

php app/console doctrine:mapping:import AppMyBundle annotation --filter="users_table"

If you wanted to yml, change annotation to yml.

warning: when you import to annotation or yml, it will delete your current entity file.

Friday, December 9, 2022

I finally solved the problem but dont know if it is the best way

I override the constructor method in connect method in ConnectionWrapper:

public function connect()

    if (!$this->session->has(self::SESSION_ACTIVE_DYNAMIC_CONN)) {
        throw new InvalidArgumentException('You have to inject into valid context first');
    if ($this->isConnected()) {
        return true;

    $driverOptions = isset($params['driverOptions']) ? $params['driverOptions'] : array();

    $params = $this->getParams();
    $realParams = $this->session->get(self::SESSION_ACTIVE_DYNAMIC_CONN);
    $params['dbname'] = $realParams[0];

    //overrride constructor in parent class Connection to set new parameter dbname
    parent::__construct($params, $this->_driver, $this->_config,$this->_eventManager);

    $this->_conn = $this->_driver->connect($params, $params['user'], $params['password'], $driverOptions);

    if ($this->_eventManager->hasListeners(Events::postConnect)) {
        $eventArgs = new ConnectionEventArgs($this);
        $this->_eventManager->dispatchEvent(Events::postConnect, $eventArgs);

    $this->_isConnected = true;

    return true;
Tuesday, August 2, 2022

If we using Realm in Android, then which method do we have to use for fetching the data of only one column?

You can't, because Realm is an object store, it doesn't have concept of "columns".

My problem:

results.size() > 10k. So I want to avoid 10k iteration

for(i = 0; i < results.size(); i++){ 

Solution: don't iterate?

 RealmResults<User> results = query.findAll();
 //List<String> name = new ArrayList<>(); 
 //for(i = 0; i < results.size(); i++){ 
 //     name.add(result.get(i).getName();
 return results;

 // ...
 String name = results.get(position).getName();
Thursday, November 10, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :