小编Eug*_*ene的帖子

如何解决"未能懒散地初始化角色集合"的Hibernate异常

我有这个问题:

org.hibernate.LazyInitializationException:懒得初始化角色集合:mvc3.model.Topic.comments,没有会话或会话被关闭

这是模型:

@Entity
@Table(name = "T_TOPIC")
public class Topic {

    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private int id;

    @ManyToOne
    @JoinColumn(name="USER_ID")
    private User author;

    @Enumerated(EnumType.STRING)    
    private Tag topicTag;

    private String name;
    private String text;

    @OneToMany(mappedBy = "topic", cascade = CascadeType.ALL)
    private Collection<Comment> comments = new LinkedHashSet<Comment>();

    ...

    public Collection<Comment> getComments() {
           return comments;
    }

}
Run Code Online (Sandbox Code Playgroud)

调用模型的控制器如下所示:

@Controller
@RequestMapping(value = "/topic")
public class TopicController {

    @Autowired
    private TopicService service;

    private static final Logger logger = LoggerFactory.getLogger(TopicController.class);


    @RequestMapping(value = "/details/{topicId}", method = RequestMethod.GET)
    public ModelAndView …
Run Code Online (Sandbox Code Playgroud)

java spring jsp hibernate spring-mvc

340
推荐指数
21
解决办法
46万
查看次数

无法找到XML架构命名空间的Spring NamespaceHandler [http://www.springframework.org/schema/data/jpa]

任何想法,什么可能导致此错误?

org.springframework.beans.factory.parsing.BeanDefinitionParsingException:配置问题:无法找到XML架构命名空间的Spring NamespaceHandler [http://www.springframework.org/schema/data/jpa]攻击资源:ServletContext资源[/ WEB- INF /弹簧/ appServlet/servlet的context.xml中]

这是我的'servle-context.xml'(缩进有一些问题,但文件太大了......):

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="http://www.springframework.org/schema/mvc 
                    http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
                    http://www.springframework.org/schema/beans 
                    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                    http://www.springframework.org/schema/tx 
                    http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
                    http://www.springframework.org/schema/data/jpa 
                    http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
                    http://www.springframework.org/schema/context 
                    http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->

<!-- Enables the Spring MVC @Controller programming model -->
<annotation-driven />

<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
<resources mapping="/resources/**" location="/resources/" />

<!-- Resolves views selected for rendering by @Controllers to …
Run Code Online (Sandbox Code Playgroud)

java spring maven-3

7
推荐指数
1
解决办法
3万
查看次数

Ranorex API无法找到Ranorex Spy找到的网络元素

我试着找一个表格行.首先,我使用了Ranorex Spy,并尝试使用以下rXpath表达式:

/dom[@domain='127.0.0.1']//table//td[@innertext='john.doe@acme.com']/../following-sibling::tr/.[1]
Run Code Online (Sandbox Code Playgroud)

Ranorex Spy成功找到并突出显示此标记.但是当我尝试使用Ranorex API找到这个元素时,它没有返回任何结果.代码如下

// path is exactly rXpath expression which is used for Ranorex Spy
IList<Ranorex.Core.Element> elements = Host.Local.Find(path);
Run Code Online (Sandbox Code Playgroud)

你能告诉我,我的错误在哪里或rXpath有什么问题吗?

.net c# xpath ranorex

5
推荐指数
1
解决办法
2740
查看次数

如何将指针传递给函数中的数组,修改它并正确返回?

我试图在函数中传递指向数组的指针并将其返回.问题是在正确初始化之后,函数返回一个NULL指针.谁能告诉我,我的逻辑有什么问题?

这是我的函数,其中声明了数组:

void main()
{
     int errCode;
     float *pol1, *pol2;
     pol1 = pol2 = NULL;
     errCode = inputPol("A", pol1);
     if (errCode != 0)
     { 
         return;
     }

     // using pol1 array

     c = getchar();
}
Run Code Online (Sandbox Code Playgroud)

这是初始化的功能:

int inputPol(char* c, float *pol)
{
    pol= (float *) calloc(13, sizeof( float ) );
    while( TRUE )
    {
         // While smth happens
         pol[i] = 42;
         i++;
    };
}
Run Code Online (Sandbox Code Playgroud)

c pointers pass-by-reference

1
推荐指数
1
解决办法
3392
查看次数

如何将调用传递给函数?

我需要将一个函数传递给另一个函数并在那里调用它.我使用以下代码:

namespace DelegateTest
{
    class Program
    {
        public class MySampleClass
        {
            public void click(string param)
            {
                System.Console.WriteLine(param + " click!");
            }

            public void flick(string param)
            {
                System.Console.WriteLine(param + " flick!");
            }
        }

        public static delegate void EventToWait(string param);

        public static void waitFor(EventToWait myEvent, string param)
        {
            // here is a **very** complex loop, which i would like wipe from main() function
            myEvent(param);
        }

        public static void Main(string[] args)
        {
            MySampleClass sc = new MySampleClass();
            EventToWait ev1 = sc.click;
            EventToWait ev2 …
Run Code Online (Sandbox Code Playgroud)

.net visual-studio-2010 c#-4.0

0
推荐指数
1
解决办法
61
查看次数