我正在尝试设置一个简单的hibernate应用程序,当我运行它时,我得到一个充满错误的堆栈跟踪.
我的文件中有以下maven依赖项pom.xml:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.0.Final</version>
</dependency>
<!-- http://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.2</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我在本地运行的mysql版本是:
5.7.9, for osx10.11 (x86_64)
Run Code Online (Sandbox Code Playgroud)
我正在运行,似乎是一种非常简单的方法,但仍然会出现错误:
// create session factory
SessionFactory factory = new Configuration()
.configure("hibernate.cfg.xml")
.addAnnotatedClass(Model.class)
.buildSessionFactory();
// create session
Session session = factory.getCurrentSession();
Model newModel = new Model("....", "...", "...");
// start a transaction
session.beginTransaction();
// save the student object
System.out.println("Saving the model...");
session.save(newModel);
Run Code Online (Sandbox Code Playgroud)
执行上面的操作后,我得到一个很长的堆栈跟踪...... System.out.println也没有打印...所以连接似乎没有连接.
INFO: HHH000115: Hibernate connection pool size: 1 (min=1)
Thu Jun 09 17:36:28 EST 2016 WARN: …Run Code Online (Sandbox Code Playgroud) 所以我想要返回数据库结果而不是别的.目前我收到了大量的JSON数据(如下所示):
但我只需要[dataValues]属性.我不想使用这一点JSON来检索它:tagData[0].dataValues.tagId.
我只是注意到:当它找到并且不创建时,它将返回JSON数据库结果,但是当它找不到并创建时,它返回不需要的JSON blob(如下所示)有没有办法解决这个问题?
[ { dataValues:
{ tagId: 1,
tagName: '#hash',
updatedAt: Fri Dec 25 2015 17:07:13 GMT+1100 (AEDT),
createdAt: Fri Dec 25 2015 17:07:13 GMT+1100 (AEDT) },
_previousDataValues:
{ tagId: 1,
tagName: '#hash',
createdAt: Fri Dec 25 2015 17:07:13 GMT+1100 (AEDT),
updatedAt: Fri Dec 25 2015 17:07:13 GMT+1100 (AEDT) },
_changed:
{ tagId: false,
tagName: false,
createdAt: false,
updatedAt: false },
'$modelOptions':
{ timestamps: true,
instanceMethods: {},
classMethods: …Run Code Online (Sandbox Code Playgroud) 所以我试图在节点js中扩展一个类,并且编译器继续返回以下错误:
TypeError: Class extends value #<Object> is not a function or null
Run Code Online (Sandbox Code Playgroud)
我检查过我正在正确导出课程,我是,有什么想法吗?我将在下面发布我的代码:
var VenueViews = require('../views/venue'); // If I remove this the error will dissapear (as expected)
class Venue {
constructor(data) {
this.setDataHere = data;
}
main () {
var View = new VenueViews(); // This doesn't run
}
}
module.exports = Venue;
Run Code Online (Sandbox Code Playgroud)
var Venue = require('../handlers/venue');
console.log (Venue) // This returns {} ???
class VenueViews extends Venue {
constructor() {
super();
}
}
module.exports = VenueViews; …Run Code Online (Sandbox Code Playgroud) 应用程序捆绑包:https : //developer.android.com/guide/app-bundle/这使Google Play可以管理签名,减小应用程序大小并允许按需提取代码,这真是太棒了!
我尝试进行设置,但是Android Studio不断告诉我我需要更新gradle版本吗?
这是我的build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
task wrapper(type: Wrapper) {
gradleVersion = '4.4' //version required
}
buildscript {
repositories {
/**
* Must stay in this order
*/
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
}
}
subprojects {
afterEvaluate { project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 27
}
}
}
}
allprojects {
repositories {
google()
jcenter()
maven { …Run Code Online (Sandbox Code Playgroud) android react-native react-native-android android-app-bundle
I've got a simple RequestMapping method that returns a list of Users, the Users model has a ONE TO MANY relation to HolidayDates...I'm just playing around with it, so I've chosen holiday dates as the relation (list of dates they went on a holiday).
So ONE user can have MANY related Dates.
@Entity
@Table(name="user")
public class User {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="userId")
private int userId;
@Column(name="about")
private String about;
// Maybe change to fetchtype eager
@OneToMany(fetch …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用AWS codebuild构建一个简单的docker应用程序,但是我遇到了一个找不到aws命令的错误:
[Container] 2016/12/10 04:29:17 Build started on Sat Dec 10 04:29:17 UTC 2016
[Container] 2016/12/10 04:29:17 Running command echo Building the Docker image...
[Container] 2016/12/10 04:29:17 Building the Docker image...
[Container] 2016/12/10 04:29:17 Running command docker build -t aws-test .
[Container] 2016/12/10 04:29:17 sh: 1: docker: not found
[Container] 2016/12/10 04:29:17 Command did not exit successfully docker build -t aws-test . exit status 127
[Container] 2016/12/10 04:29:17 Phase complete: BUILD Success: false
[Container] 2016/12/10 …Run Code Online (Sandbox Code Playgroud) amazon-ec2 amazon-web-services amazon-ecs docker aws-codebuild
我是新来的React及React native,我试图retrieve data from an API然后渲染它,但我似乎遇到了问题.
我可以从中获取数据API,但是当我尝试render它时,我会遇到各种各样的错误.
基本上我所要做的就是渲染从API返回的照片.应该简单吧?非常感谢能够指引我走上正轨的人.
我收到的错误如下:
undefined不是RenderPhotos_render中的对象(评估'this.props.photos')
我可能已经React Native太早了......所以请原谅我缺乏知识!
var AwesomeProject = React.createClass({
getInitialState: function() {
return {
isLoading: true,
photos: this.props.photos
};
},
componentWillMount: function(){
fetch("http://localhost:3000/api/photos/", {
method: "GET",
headers: {
"x-access-token":"xxxxx",
"x-key":"xxxx"
},
})
.then((response) => response.json())
.then((responseData) => {
AlertIOS.alert(
"GET Response",
"Search Query -> " + JSON.stringify(responseData)
)
this.setState({
isLoading: false
});
this.setState({
photos: JSON.stringify(responseData)
});
})
.done();
},
render: function() …Run Code Online (Sandbox Code Playgroud) 我正在尝试处理 Spring Rest 服务中的验证异常,如下所示:
@Produces("application/json")
@ExceptionHandler(MethodArgumentNotValidException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
public @ResponseBody ResponseEntity<ValidationErrorDTO> processValidationError(MethodArgumentNotValidException ex) {
BindingResult result = ex.getBindingResult();
List<FieldError> fieldErrors = result.getFieldErrors();
ResponseEntity<ValidationErrorDTO> re = new ResponseEntity<>(processFieldErrors(fieldErrors), HttpStatus.BAD_REQUEST);
return re;
}
Run Code Online (Sandbox Code Playgroud)
但是,当此代码执行时,它会返回附加到 JSON 响应的堆栈跟踪。我想摆脱这个堆栈跟踪,只返回 JSON 错误响应。这在 Spring 3.1 中可行吗?
{"fieldErrors":
[{"field":"type","message":"Pattern.shippingAddress.type"}]}<pre>javax.servlet.ServletException: 400 Bad Request null
at com.ebay.raptor.kernel.dispatcher.HttpDispatchCommand.execute(HttpDispatchCommand.java:142)
at com.ebay.ebox.pres.cmd.preshandler.CommandDispatchHandler.handleRequest(CommandDispatchHandler.java:59)
at com.ebay.ebox.pres.cmd.preshandler.CommandDispatchHandler.handleRequest(CommandDispatchHandler.java:13)
at com.ebay.ebox.pres.cmd.preshandler.CommandHandlerFactory$CalHandler.handleRequest(CommandHandlerFactory.java:114)
at com.ebay.ebox.pres.cmd.preshandler.CommandHandlerFactory$CalHandler.handleRequest(CommandHandlerFactory.java:75)
at com.ebay.kernel.pipeline.RequestPipeline.invoke(RequestPipeline.java:18)
at com.ebay.kernel.pipeline.RequestPipeline.invoke(RequestPipeline.java:12)
at com.ebay.kernel.pipeline.BasePipeline.callHandler(BasePipeline.java:75)
at com.ebay.kernel.pipeline.BasePipeline.execute(BasePipeline.java:53)
at com.ebay.ebox.pres.stage.BaseCommandRequestStageImpl.doWork(BaseCommandRequestStageImpl.java:64)
at com.ebay.kernel.stage.StageDriver.execute(StageDriver.java:55)
at com.ebay.ebox.pres.cmd.WebCommandImpl.execute(WebCommandImpl.java:30)
at com.ebay.raptor.web.RaptorFrontController.process(RaptorFrontController.java:338)
at com.ebay.raptor.web.RaptorFrontController.doPost(RaptorFrontController.java:554)
at com.ebay.raptor.web.RaptorGenericController.service(RaptorGenericController.java:64)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) …Run Code Online (Sandbox Code Playgroud) 这是让我烦恼的一件事!我必须为几乎相同的查询编写2个不同的函数!
假设我有一个返回的API posts与特定的typeId和cityId.为了获得ALL了关联到职位typeId 1 OR 2, OR 3 和 cityId 1我会解析以下我sequelize findAll查询:
$or: [{typeId: 1}, {typeId: 2}, {typeId: 3}]
cityId: 1
Run Code Online (Sandbox Code Playgroud)
但是说我希望得到所有帖子,cityId = 1 andOr typeId = 1,2,3,4,5,6,7,8,9,10,etc...我不能做以下事情:
var types = [{typeId: 1}, {typeId: 2}, {typeId: 3}]
Post.findAll({
where: {
if (types != []) $or: types,
cityId: 1
}
Run Code Online (Sandbox Code Playgroud)
所以我必须创建一个不包含$or: typeswhere子句的新查询...因为如果我解析一个空types数组,我得到一个奇怪的sql输出:
WHERE 0 = 1 AND `post`.`cityId` = '1'
Run Code Online (Sandbox Code Playgroud)
注意它是如何输出0 = 1的?不知道为什么
当我在 CircleCI 上运行我的测试时,它会多次记录以下消息,最终测试失败,因为由于死锁,没有任何数据库方法可以检索数据:
{
"message": "Error running raw sql query in pool.",
"stack": "error: deadlock detected\n at Connection.Object.<anonymous>.Connection.parseE (/home/circleci/backend/node_modules/pg/lib/connection.js:567:11)\n at Connection.Object.<anonymous>.Connection.parseMessage (/home/circleci/-backend/node_modules/pg/lib/connection.js:391:17)\n at Socket.<anonymous> (/home/circleci/backend/node_modules/pg/lib/connection.js:129:22)\n at emitOne (events.js:116:13)\n at Socket.emit (events.js:211:7)\n at addChunk (_stream_readable.js:263:12)\n at readableAddChunk (_stream_readable.js:250:11)\n at Socket.Readable.push (_stream_readable.js:208:10)\n at TCP.onread (net.js:597:20)",
"name": "error",
"length": 316,
"severity": "ERROR",
"code": "40P01",
"detail": "Process 1000 waits for AccessExclusiveLock on relation 17925 of database 16384; blocked by process 986.\nProcess 986 waits for RowShareLock on relation 17870 of database 16384; blocked by process …Run Code Online (Sandbox Code Playgroud) java ×3
javascript ×3
json ×3
react-native ×2
sequelize.js ×2
spring ×2
amazon-ec2 ×1
amazon-ecs ×1
android ×1
circleci ×1
docker ×1
ecmascript-6 ×1
hibernate ×1
jackson ×1
jestjs ×1
maven ×1
mysql ×1
node.js ×1
reactjs ×1
rest ×1
spring-mvc ×1