小编Geo*_*inc的帖子

hibernate非法尝试将集合与两个打开的会话相关联

我在学校的项目中使用持久性,当我尝试删除和更新对象时,我遇到了问题,所有其他查询都有效.

例外是:

Illegal attempt to associate a collection with two open sessions
Run Code Online (Sandbox Code Playgroud)

我关闭了我打开的每个会话.

HibernateUtils代码

public class Hibernate
{
 protected static final SessionFactory sessionFactory;

 private Session session;

 static 
 {
  try 
  {
   // Create the SessionFactory from hibernate.cfg.xml
   sessionFactory = new Configuration().configure().buildSessionFactory();
   session
  } 
  catch (Throwable ex) 
  {
   // Make sure you log the exception, as it might be swallowed
   System.err.println("Initial SessionFactory creation failed." + ex);
   throw new ExceptionInInitializerError(ex);
  }
 }

 public void create(Object obj)
 {
  this.session = sessionFactory.openSession();
  session.getTransaction().begin();
  session.save(obj);
  session.getTransaction().commit(); …
Run Code Online (Sandbox Code Playgroud)

java hibernate

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

Word VSTO覆盖CTRL + Z/CTRL + Y.

我正在寻找一种方法来覆盖Word 2010中的Undo(CtrlZ)/ Redo(CtrlZ)命令(C#+ VSTO).可能吗 ?

我设法捕获复制/粘贴命令,但似乎Undo/Redo不是RibbonUI中的命令,如复制/粘贴.

c# vsto ms-word

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

将IRandomAccessStreamWithContentType转换为Byte []

在我的应用程序中,我允许用户使用ContactPicker从联系人中添加人员.

我尝试将IRandomAccessStreamWithContentType转换为Byte []

IRandomAccessStreamWithContentType stream = await contactInformation.GetThumbnailAsync();
if (stream != null && stream.Size > 0)
{
    Byte[] bytes = new Byte[stream.Size];
    await stream.ReadAsync(bytes.AsBuffer(), (uint)stream.Size, Windows.Storage.Streams.InputStreamOptions.None);
Run Code Online (Sandbox Code Playgroud)

我的字节[]不为空(约10000字节)

但是当我使用Converter Byte []到ImageSource时,BitmapImage的宽度和高度为0.

我将这个转换器用于另一个应用程序,它工作得很好......

public object Convert(object value, Type targetType, object parameter, string language)
{
    try
    {
        Byte[] bytes = (Byte[])value;
        if (bytes == null)
           return (new BitmapImage(new Uri((String)parameter)));
        BitmapImage bitmapImage = new BitmapImage();
        IRandomAccessStream stream = this.ConvertToRandomAccessStream(new MemoryStream(bytes));
        bitmapImage.SetSource(stream);
        return (bitmapImage);
    }
    catch
    {
       return (new BitmapImage(new Uri((String)parameter)));
    }

}
private IRandomAccessStream …
Run Code Online (Sandbox Code Playgroud)

c# windows-runtime

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

标签 统计

c# ×2

hibernate ×1

java ×1

ms-word ×1

vsto ×1

windows-runtime ×1