You have not set a script to run. Set it with #custom:dev-run-script NatSpec tag
The notification message
I have written a simple program of Hello World in the Remix IDE.
It's an easy fix -
Just add these lines before declaring your contract.
/**
* #title ContractName
* #dev ContractDescription
* #custom:dev-run-script file_path
*/
contract ContractName {}
Learn more from here
I'm learning c++ web develoment .
I what save my data by MySql database .
my env
Apple M1
Docker Debian 11 Arm64
"Mysql8" and "MySQL Connector/C++ 8"
My question
I don't know how to use parameterized query .
my error code ①
SqlStatement sqlStatement = session.sql("SELECT * FROM ?.?")
.bind(nameless_carpool, user);
SqlResult sqlResult = sqlStatement.execute();
/*
I guses the api will got sql is :
SELECT * FROM ?.? -> SELECT * FROM 'nameless_carpool'.'user'
In fact error message :
terminate called after throwing an instance of 'mysqlx::abi2::r0::Error'
what(): CDK Error: You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version
for the right syntax to use near ''nameless_carpool'.'user'' at line 1
*/
My right code ②
SqlStatement sqlStatement = session.sql("SELECT * FROM nameless_carpool.user");
SqlResult sqlResult = sqlStatement.execute();
/*
use the code , i can get my table info .
but i want use parameterized query
*/
Will anyone help me ?
slack friend Nik told me :
I don't think that will work. Using ? will escape the values as values, not for table names. Typically, you would use parameterized queries for values only.
For example, as you have seen, this doesn't work:
SELECT * FROM 'nameless_carpool'.'user'
It should be this:
SELECT * FROM `nameless_carpool`.`user`
But this is not what parameterized queries are typically for. It would be used for values, eg:
SELECT * FROM `nameless_carpool`.`user` WHERE `driver_name` = ?
which would turn into something like:
SELECT * FROM `nameless_carpool`.`user` WHERE `driver_name` = 'Wukong'
I know this from working with MySQL and other databases. It is not common to need a variable to reference a table. If you do, the application should handle this without directly taking user input
I was following the Symfony tutorial and was creating a repository for my product entity by hand and not using the console to create it. Originally the annotation looked like this:
/**
* Product
*
* #ORM\Table(name="product")
* #ORM\Entity(repositoryClass="AppBundle\Entity\ProductRepository")
*/
but as I am learning to use the console to create the Entities and Repositories I have tried changing it so that it is in the correct place. The console placed all the console created ones in the Repository directory instead. My product entity now looks like this (changed by hand):
/**
* Product
*
* #ORM\Table(name="product")
* #ORM\Entity(repositoryClass="AppBundle\Repository\ProductRepository")
*/
However when I issue this command
# php bin/console doctrine:generate:entities AppBundle
OR
# php bin/console doctrine:generate:entities AppBundle/Entity/Product
the repository ends up in the Entity directory, not the Repository one. I have looked up this issue and looks like Doctrine caches but I have tried the following commands to clear it with no luck:
php bin/console doctrine:cache:clear-metadata
php bin/console doctrine:cache:clear-query
php bin/console doctrine:cache:clear-result
I have even tried recreating the Entity via the console but it continues to create the file in the wrong place. Occasionally it places it in the correct place for one refresh of the browser but then complains it cant find it (since it is looking for it in the Entity directory.
Anyone help me straighten out Doctrine? Here are my classes so you can see fully:
<?php
namespace AppBundle\Entity; //<--- This is one of the issues. See answer
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* Product
*
* #ORM\Table(name="product")
* #ORM\Entity(repositoryClass="AppBundle\Repository\ProductRepository")
*/
class Product
{
/**
* #var int
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
...
If anyone tried but didn't comment back on this, thanks to anyone who took time to look this over.
The answer was stupidity on my part. I created the project while I was logged in as root instead of the web user so the cached metadata files were not able to be overwritten. I found this out by running the following command:
# php bin/console cache:clear
and got ....
[InvalidArgumentException]
The directory "/path/to/testapp/var/cache/dev/annotations" is not writable.
(path above modified to mask real path). Secondly the name of the namespace in my class was clearly wrong. It should have been:
namespace AppBundle\Repository;
Anyhow thanks.
Something is wrong with documentation or me. I do all what documentation says.
When i put in terminal :
$ php vendor/bin/doctrine orm:schema-tool:create
Output is :
No Metadata Classes to process
I read to many posts, and google and try to many examples but nothing.
http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/tutorials/getting-started.html
I think you took the config example from Doctrine2: getting started:
$isDevMode = true;
$config = Setup::createAnnotationMetadataConfiguration([__DIR__."/src"], $isDevMode);
The trick is now that the Setup::createAnnotationMetadataConfiguration method uses a SimpleAnnotationReader by default. You can change this behaviour by changing the fifth parameter to false:
$isDevMode = true;
$config = Setup::createAnnotationMetadataConfiguration([__DIR__."/src"], $isDevMode, null, null, false);
This will force Doctrine to use the not-simple AnnotationReader which can handle your models now!
TL;DR: Make sure the type of metadata you created matches the "create metadata configuration" method you used.
I encountered the same problem while working through the Doctrine "Getting Started" guide. After looking through the Doctrine code a bit I figured out what was going wrong. Basically, the code in the tutorial in the "Obtaining the EntityManager" section is:
$config = Setup::createAnnotationMetadataConfiguration([__DIR__ . "/src"], $isDevMode);
A little further in the tutorial, in the "Starting with the Product" section, it shows us how to set up the metadata, with an example for each of the possible options for this. The tutorial says:
Metadata for entities are configured using a XML, YAML or Docblock Annotations. This Getting Started Guide will show the mappings for all Mapping Drivers. References in the text will be made to the XML mapping.
Because of this statement, I decided to use the XML configuration. Unfortunately, the createAnnotationMetadataConfiguration method in the tutorial code did not seem to be using the XML file I had created. (In hindsight, it seems much more obvious that this method is specifically referring to annotation metadata, not XML metadata!)
After I changed it to createXMLMetadataConfiguration instead, it worked as expected. So it looks like one possible source of this problem is that the "create metadata configuration" method you used may not match the type of metadata you created.
Try clearing the cache:
sudo -u www-data php app/console cache:clear --env=dev
Uncomment the one of the following lines in bootstrap.php:
// or if you prefer yaml or XML
//$config = Setup::createXMLMetadataConfiguration(array(__DIR__."/config/xml"), $isDevMode);
//$config = Setup::createYAMLMetadataConfiguration(array(__DIR__."/config/yaml"), $isDevMode);
Which depends if you created yaml or xml meta config files...
Hope this helps.
Had the same issue with custom Doctrine installation. My solution was to re-set metadata driver:
$config->setMetadataDriverImpl(
new Doctrine\ORM\Mapping\Driver\AnnotationDriver(
new Doctrine\Common\Annotations\CachedReader(
new Doctrine\Common\Annotations\AnnotationReader(),
new Doctrine\Common\Cache\ArrayCache()
),
ENTITY_DIR
)
);
Solution from http://support.skipper18.com/1120/how-use-external-tools-generate-doctrine-getters-and-setters?show=1121#a1121
My scenario was generating entities from existing database
The newDefaultAnnotationDriver adds the namespace and the method comments state the following:
If $useSimpleAnnotationReader is true, the notation #Entity will
work, otherwise, the notation #ORM\Entity will be supported.
I had the same problem when creating a new doctrine config in a new ZF2 module.
problem was caused by
'User\Entity' => 'property_entities'
the user part was from the old entity
'Property\Entity' => 'property_entities'
Changing that fixed the issue
If you're using the XML mapping (using Setup::createXMLMetadataConfiguration()), you might want to pay attention to the following:
That your XML mapping files ends by .dcm.xml, not only by .xml.
That your XML file contains the full entity classname, inclusive of the namespace. For example, for a class Company\Solution\Models\User, you must have the Company.Solution.Models.User.dcm.xml mapping file in your XML path.
In my case, the issue was with the number of asterisk used for the annotation
<?php
namespace Models;
use Doctrine\ORM\Annotation\{Id, Column, GeneratedValue, Entity};
/** // I originally used one asterisk here and kept getting the error in question. Error disappeared after doubling the asterisk as it is in this answer
* #Entity(repositoryClass="Doctrine\ORM\Annotation\Id")
*/
class User {
}
?>
you must add the docstring for example:
<?php
// src/User.php
use Doctrine\ORM\Mapping as ORM;
/**
* #ORM\Entity
* #ORM\Table(name="users")
*/
class User
{
/**
* #ORM\Id
* #ORM\Column(type="integer")
* #ORM\GeneratedValue
*/
private $id;
/**
* #ORM\Column(type="string")
*/
private $name;
}
Try the following command:
php vendor/bin/doctrine-module orm:schema-tool:create
I have a registered cqListener on a region. How can i get the actual error why onError had occured from the parameter of the method const gemfire::CqEvent& cqEvent?
I checked the documentation but it seems they don't have any method on the CqEvent class that can acctually retrieve a possible error.
#Alex
Hi Alex,
See what documentation says:
/**
* This method is invoked when there is an error during CQ processing.
* The error can appear while applying query condition on the event.
* e.g if the event doesn't has attributes as specified in the CQ query.
* This event does contain an error. The newValue may or may not be
* available, and will be NULLPTR if not available.
*/
virtual void onError(const CqEvent& aCqEvent);
It explicitly mentions "This event does contain an error". and CqEvent also does not contain method to get the error.