Doctrine2 annotation issue - orm

I have a project that uses Doctrine 2.0, works rather well. I tried to upgrade to 2.2.2, however I have noticed several differences:
/**
* Entities\Log
*
* #ORM\Table(name="log")
* #ORM\Entity(repositoryClass="Repositories\LogRepository")
*/
Is how it is shown in 2.2.2.
But this is how it is shown in 2.0.x:
/**
* Entities\Log
*
* #Table(name="log")
* #Entity(repositoryClass="Repositories\LogRepository")
*/
If I convert the 2.2.2, to look like 2.0, everything is fine, it loads up, and there is a copy of the object in cache. However, when I leave it alone I get this error:
Application Path: /www/sites/diracianbilling-repository/trunk/application
Fatal error: Uncaught exception 'Doctrine\ORM\Mapping\MappingException' with message 'Class Entities\Log is not a valid entity or mapped super class.' in /usr/share/php/Doctrine/ORM/Mapping/MappingException.php:147
Stack trace:

I guess that you generated your entities from the database.
Doctrine 2.2.2 for some reason generates these annotations that itself cannot parse. This is obviously a bug.
As a workaround you can configure the generator to provide 2.0-style annotations. Use the solution from dminer and add the following line just before generating:
$generator->setAnnotationPrefix("");

Related

aurelia-cli error when using buffer.js - global undefined

Created a new project using the aurelia-cli - SystemJS bundler option.
installed htmlparser2 module from npm which has buffer.js as a dependency.
getting the following error when attempting to import htmlparser2:
bluebird.core.js:3434 Error: global is not defined
Evaluating http://localhost:9000/buffer/index
upon inspecting vendor-bundle -> this is the line that creates the error:
Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
? global.TYPED_ARRAY_SUPPORT
: typedArraySupport()
found a similar issue with angualar-cli where the solution was to manually turn on node global
Node global is turned off. It works fine if I manually turn it on again.
The question is how to do this using the aurelia-cli? Any suggestions?
larger code snippet from vendor-bundle
define('buffer/index',['require','exports','module','base64-js','ieee754','isarray'],function (require, exports, module) {/*!
* The buffer module from node.js, for the browser.
*
* #author Feross Aboukhadijeh <feross#feross.org> <http://feross.org>
* #license MIT
*/
/* eslint-disable no-proto */
'use strict'
var base64 = require('base64-js')
var ieee754 = require('ieee754')
var isArray = require('isarray')
exports.Buffer = Buffer
exports.SlowBuffer = SlowBuffer
exports.INSPECT_MAX_BYTES = 50
/**
* If `Buffer.TYPED_ARRAY_SUPPORT`:
* === true Use Uint8Array implementation (fastest)
* === false Use Object implementation (most compatible, even IE6)
*
* Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
* Opera 11.6+, iOS 4.2+.
*
* Due to various browser bugs, sometimes the Object implementation will be used even
* when the browser supports typed arrays.
*
* Note:
*
* - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
* See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
*
* - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
*
* - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
* incorrect length in some situations.
* We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
* get the Object implementation, which is slower but behaves correctly.
*/
Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
? global.TYPED_ARRAY_SUPPORT
: typedArraySupport()
I believe you are using cli built-in bundler (I wrote it), not webpack.
Yes, nodejs global var global is currently not supported. Also nodejs global vars process and Buffer have similar issues.
The cli doc has a patch to support process and Buffer.
import process from 'process';
window.process = process;
import {Buffer} from 'buffer';
window.Buffer = Buffer;
You can try to add one more patch for global.
window.global = window;
Ok why cli has the issue
cli's tracing algorithm uses rjs (requirejs optimizer) parser, it's bit old, does not detect global vars (technically it does not do variable scope analysis).
I have another WIP bundler called dumber which solved the limitation with a new parser which detects global vars. It automatically patch nodejs global vars at module level based on need.
In long term, we will drop the code for cli built-in bundler, then wrap dumber and make it backward compatible.

Creating a Sequelize Dialect for new Database

I'm pretty new to sequelize, though I've worked on node previously I did not use any ORM framework. At present I'm using new SQL DB(which is not supported by sequelize ) and want to connect it using node.js and sequelize( popular ORM for node.js ) by prototyping the existing dialects
The configuration is correct as I've tried it wihtout ORM.
The problem is after configuring the connection with properties the
sequelize.authenticate() doesn't throw any error but doesn't return a promise back
/**
* Test the connection by trying to authenticate
*
* #error 'Invalid credentials' if the authentication failed (even if the database did not respond at all...)
* #return {Promise}
*/
authenticate(options) {
return this.query('SELECT 1+1 AS result', _.assign({ raw: true, plain: true }, options)).return();
}
The return statement doesn't return anything. I've read this post how to create a new dialect. Though it says it is not encouraged to create a new dialect and throws an error if we try to, I think there must be a way to create because if it can be created for other SQL databases then may be there should be a way to do it. This is an open source project on github. Did anyone previously work on this any help is appreciated. Thanks in Advance
Only the 5 dialects are supported and an error will be thrown if you try and use NewSQL.
There is a lot of code in Sequelize to construct queries based on the dialect, so even if you could get past the error (such as forking the repo and changing it) the likelihood of everything working as you expect (or as is documented) is low.
I suggest posting an issue on GitHub to bring that dialect to the project.

nelmio api doc bundle not render input type

Im using Nelmio API Doc Bundle to expose my api documentation. I use it with base configuration. Also using Symfony 3.1. But on controller even when i define the input parameter inside ApiDoc annotation the documentation does not show the input.
* #ApiDoc(
* section="Customer",
* description="Request reset password",
* input="AppBundle\Form\ResendConfirmationEmailType",
* statusCodes={
* 200="Returned when successful",
* 500="Returned on not found Customer"
* },
* tags={
* "beta" = "#4A7023",
* "v2" = "#ff0000"
* }
* )
There is any configuration im missing? or any known bug?
Thanks
It's a known bug. https://github.com/nelmio/NelmioApiDocBundle/issues/208
And it's not really a bug, rather it's outdated approach, used in Symfony up to 2.6, I believe.
The solution is simple - declare you FormType as a service, use, implement a getName for it, and then use an alias in input.
* input="resend_confirmation_type",

Strange java.beans.Introspector behavior on WebLogic with DCEVM and HotSwapAgent

I am running WebLogic on JVM 1.7 with DCEVM (full implementation) and HotSwapAgent with custom plugin that gets triggered on every onClassLoad.
I run into problems with Freemarker, which uses java.beans.Introspector. What I discovered is the fact that when I call Introspector.flushCaches on the method called by HotSwapAgent (through ReflectionCommand), then the BeanInfo in Introspector is invalidated properly (checked with debugger in that thread). However when I make request to the WLS appserver, then Introspector for the worker thread shows the old values!
This seems like some thread-local implementation, but I was not able to find anything that would point to that assumption in java.beans.Introspector's documentation.
Does anybody have any clue why this is happening and how to resolve that?
Currently I store the information about reloaded classes in separate class and reload everything that's in that cache from the request thread, which works.
Thanks for any clue.
Found this thanks to #ddekany and his answer to related problem at Freemarker removeIntrospectionInfo does not work with DCEVM after model hotswap
It seems that JVM (at least HotSpot 1.7) caches Introspector's cache per ThreadGroup. This means, that Introspector.flushCaches must be called in a thread that runs in corresponding ThreadGroup.
When I executed this for all the ThreadGroups in the application then everything started working again properly.
I wasn't able to find any documentation why the java.beans.Introspector is cached per ThreadGroup so if anybody has an reliable information to this, please add a comment with link.
Thanks.
Update:
Comming from JDK7 source
/**
* Introspect on a Java Bean and learn about all its properties, exposed
* methods, and events.
* <p>
* If the BeanInfo class for a Java Bean has been previously Introspected
* then the BeanInfo class is retrieved from the BeanInfo cache.
*
* #param beanClass The bean class to be analyzed.
* #return A BeanInfo object describing the target bean.
* #exception IntrospectionException if an exception occurs during
* introspection.
* #see #flushCaches
* #see #flushFromCaches
*/
public static BeanInfo getBeanInfo(Class<?> beanClass)
throws IntrospectionException
{
if (!ReflectUtil.isPackageAccessible(beanClass)) {
return (new Introspector(beanClass, null, USE_ALL_BEANINFO)).getBeanInfo();
}
ThreadGroupContext context = ThreadGroupContext.getContext();
BeanInfo beanInfo;
synchronized (declaredMethodCache) {
beanInfo = context.getBeanInfo(beanClass);
}
if (beanInfo == null) {
beanInfo = new Introspector(beanClass, null, USE_ALL_BEANINFO).getBeanInfo();
synchronized (declaredMethodCache) {
context.putBeanInfo(beanClass, beanInfo);
}
}
return beanInfo;
}
This has been definitely added in JDK7, because I checked JDK6 code and it's not there!.

Building modified AOSP throws error (Trying to change API)

out/target/common/obj/PACKAGING/public_api.txt:4316: error 5: Added public field android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_MOVEMENT
******************************
You have tried to change the API from what has been previously approved.
To make these errors go away, you have two choices:
1) You can add "#hide" javadoc comments to the methods, etc. listed in the
errors above.
2) You can update current.txt by executing the following command:
make update-api
To submit the revised current.txt to the main Android repository,
you will need approval.
******************************
So i tried to add an #hide annotation to my member variable, but it will only give me another error:
frameworks/base/core/java/android/app/admin/DevicePolicyManager.java:233: cannot find symbol
symbol : class hide
location: class android.app.admin.DevicePolicyManager
#hide
How can I solve this problem?
I made the mistake of using #hide such as #Override, but you have to use it in a JavaDoc comment:
/**
* #hide
*/