symfony 2 - Attempted to call an undefined method named "findBy" of class "testBundle\Entity\test"

cnmicha

I can't get data out of the database. Here's the code:

$testRepository= $this->getDoctrine()->getRepository('testBundle:test');
    $potds = $testRepository->findBy(
        array(),
    );

Here's the entity class:

 * @ORM\Table()
 * @ORM\Entity(repositoryClass="testBundle\Entity\test")
 * @ORM\HasLifecycleCallbacks
 */
class test
{ /* ... */ }

Here's the code of the Repository:

namespace testBundle\Entity;

/**
 * TestRepository
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class testRepository extends \Doctrine\ORM\EntityRepository
{
}

I get this error message: symfony 2 - Attempted to call an undefined method named "findBy" of class "testBundle\Entity\test"

Inserting data with Doctrine works, so there should be everything right with the Entity.

Kamil Adryjanek

You have incorrect repository class definition:

@ORM\Entity(repositoryClass="testBundle\Entity\test")

Should be:

@ORM\Entity(repositoryClass="testBundle\Entity\testRepository")

For now this code:

$testRepository= $this->getDoctrine()->getRepository('testBundle:test');

is returning entity class, not repository.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Attempted to call an undefined method named "query" of class

From Dev

Attempted to call an undefined method named "getpreReady" (Twig & Symfony3)

From Dev

Attempted to call an undefined method named "setCurrentUri" of class "Knp\Menu\MenuItem"

From Dev

Attempted to call an undefined method named "request" of class "Zend\Http\Client"

From Dev

Attempted to call method "getDoctrine" on class (Symfony)

From Dev

I get error "Attempted to call method "generateUrl" on class" Symfony 2.6

From Dev

Attempted to call method "getDoctrine" on class "Symfony\Component\HttpFoundation\Response"

From Dev

Symfony2: Call to undefined method Doctrine\ORM\QueryBuilder::getResult()

From Dev

Symfony2: Call to undefined method Doctrine\ORM\QueryBuilder::getResult()

From Dev

Symfony 3 - undefined method named "getResult"

From Dev

Symfony2 findBy method with property from relationship

From Dev

Symfony2 - Method name must begin with findBy or findOneBy

From Dev

Attempted to load class "COM" from namespace -Symfony2

From Dev

Simfony2 Service within a Service Attempted to call method "get"

From Dev

Symfony - Attempted to load class - ClassNotFoundException

From Dev

Symfony2 - Fatal error: Call to undefined method Symfony\Bundle\DoctrineBundle\Registry::getManager()

From Dev

get an error at compilation "attempted to call undefined method in my controller on my bundle"

From Dev

Attempted to load class "Class" from the global namespace. Error Symfony2

From Dev

Emberjs 1.0 named templates: Cannot call method 'connectOutlet' of undefined

From Dev

Emberjs 1.0 named templates: Cannot call method 'connectOutlet' of undefined

From Dev

Nested queries using symfony findBy method

From Dev

Symfony 2 - Attempted to call function "apcu_fetch" from namespace "Doctrine\Common\Cache"

From Dev

ClassNotFoundException: Attempted to load class... Symfony

From Dev

ClassNotFoundException: Attempted to load class... Symfony

From Dev

Symfony2: Undefined method: getDoctrine()

From Dev

Symfony2 and Doctrine entity undefined method

From Dev

Symfony2 and Doctrine entity undefined method

From Dev

Symfony 2 Attempted to load class " " from namespace " " Did you forget a "use" statement for another namespace?

From Dev

Sonata, Sf2 : Attempted to call method "ifTrue" on route /classification/context/create

Related Related

  1. 1

    Attempted to call an undefined method named "query" of class

  2. 2

    Attempted to call an undefined method named "getpreReady" (Twig & Symfony3)

  3. 3

    Attempted to call an undefined method named "setCurrentUri" of class "Knp\Menu\MenuItem"

  4. 4

    Attempted to call an undefined method named "request" of class "Zend\Http\Client"

  5. 5

    Attempted to call method "getDoctrine" on class (Symfony)

  6. 6

    I get error "Attempted to call method "generateUrl" on class" Symfony 2.6

  7. 7

    Attempted to call method "getDoctrine" on class "Symfony\Component\HttpFoundation\Response"

  8. 8

    Symfony2: Call to undefined method Doctrine\ORM\QueryBuilder::getResult()

  9. 9

    Symfony2: Call to undefined method Doctrine\ORM\QueryBuilder::getResult()

  10. 10

    Symfony 3 - undefined method named "getResult"

  11. 11

    Symfony2 findBy method with property from relationship

  12. 12

    Symfony2 - Method name must begin with findBy or findOneBy

  13. 13

    Attempted to load class "COM" from namespace -Symfony2

  14. 14

    Simfony2 Service within a Service Attempted to call method "get"

  15. 15

    Symfony - Attempted to load class - ClassNotFoundException

  16. 16

    Symfony2 - Fatal error: Call to undefined method Symfony\Bundle\DoctrineBundle\Registry::getManager()

  17. 17

    get an error at compilation "attempted to call undefined method in my controller on my bundle"

  18. 18

    Attempted to load class "Class" from the global namespace. Error Symfony2

  19. 19

    Emberjs 1.0 named templates: Cannot call method 'connectOutlet' of undefined

  20. 20

    Emberjs 1.0 named templates: Cannot call method 'connectOutlet' of undefined

  21. 21

    Nested queries using symfony findBy method

  22. 22

    Symfony 2 - Attempted to call function "apcu_fetch" from namespace "Doctrine\Common\Cache"

  23. 23

    ClassNotFoundException: Attempted to load class... Symfony

  24. 24

    ClassNotFoundException: Attempted to load class... Symfony

  25. 25

    Symfony2: Undefined method: getDoctrine()

  26. 26

    Symfony2 and Doctrine entity undefined method

  27. 27

    Symfony2 and Doctrine entity undefined method

  28. 28

    Symfony 2 Attempted to load class " " from namespace " " Did you forget a "use" statement for another namespace?

  29. 29

    Sonata, Sf2 : Attempted to call method "ifTrue" on route /classification/context/create

HotTag

Archive