Position:Home > MySQL数据插入、修改、删除

MySQL数据插入、修改、删除

up vote 1 down vote favorite

I'm new with AspectJ and I try to do this:

This is my current Code.

public class MyDBDAO {
    public boolean update(MyObject myObject) {}
}

And Aspect:

@Aspect
@Component
public class AspectJClass {
   @Pointcut("execution(* com.myclass.MyDBDAO.update()) && args(myObject)")
    public void update(MyObject myObject) {}
 }

Should I only use absoulute Type? Are there any ways to solve this problem?

java spring aspectj args pointcut share | improve this question asked Feb 17 '16 at 13:23 ellen 8 3      What exactly are you trying to do? –  Austin D Feb 17 '16 at 14:07      I wanna validate the parameter in the aspect class before inserting DB. –  ellen Feb 18 '16 at 1:58 add a comment  | 

1 Answer 1

active oldest votes up vote 0 down vote accepted

have you tried this ?

Recommend:笔记301 触发器记录表某一个字段数据变化的日志 包括插入insert 修改update 删除delete 操作 2013-6-18

笔记301 触发器记录表某一个字段数据变化的日志 包括插入insert 修改update 删除delete 操作 2013-6-18 1 --触发器记录表某一个字段数据变化的日志 包括插入insert 修改update 删除delete 操作 2013-6-18 2 -- 建测试表 3 USE [p

@Pointcut("execution(void com.myclass.MyDBDAO.update(MyObject)) && args(myObject)")
public void update(MyObject myObject) {}

if you want poincut to all of the methods in the class you can do this :

@Pointcut("this(com.myclass.MyDBDAO)")
public void isMyDBDAO() {}
share | improve this answer answered Feb 17 '16 at 13:49 Yair Harel 161 1 8      Thnanks for answer! I tried the first one. But I got this message. Caused by: java.lang.IllegalArgumentException: warning no match for this type name: MyObject [Xlint:invalidAbsoluteTypeName] at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpress‌​ion(PointcutParser.j‌​ava:301) at org.springframework.aop.aspectj.AspectJExpressionPointcut.bu‌​ildPointcutExpressio‌​n(AspectJExpressionP‌​ointcut.java:195) at –  ellen Feb 17 '16 at 13:59      can you post your advice code ? –  Yair Harel Feb 17 '16 at 18:18      I have just closely re-read your exception and you need to specify the full path of the class MyObject for example com.myclass.MyObject inside the pointcut. you didn't post your advice but note that an advice that advices this pointcut must also have MyObject as parameter –  Yair Harel Feb 17 '16 at 20:37      Thanks!! I finally solved the problem. I wrote pointcut like this. @Pointcut("execution(void com.myclass.MyDBDAO.update(com.model.MyObject)) && args(myObject)") public void update(MyObject myObject) {} –  ellen Feb 18 '16 at 1:59 add a comment  | 

Your Answer

  draft saved draft discarded

Sign up or log in

Sign up using Google

Sign up using Facebook

Sign up using Email and Password

Post as a guest

Name Email

Post as a guest

Name Email discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged java spring aspectj args pointcut or ask your own question.

Recommend:MongoDB修改删除数据

将name是mongo的记录的name修改为mongo_new   db.things.update({name:"mongo"},{$set:{name:"mongo_new"}});   我们来查询一下是否改过来了 > db.things.find();{ "_id" : ObjectId("501c7e65ab2f3c46faf8e68b"), "x" : 3 }{ "_id"

Recommend:C# 从数据库中删除,插入,修改 索引选中条目

一。删除 1. while (usrListView.SelectedIndex != -1) { var currentSelectIndex = usrListView.SelectedIndex; var item = usrView[currentSelectIndex];

Your Answer
(Ctrl+Enter To Post)   
    Copyright © 2015-2017 163JAVA.COM All Rights Reserved.