Daily Archives

Articles indexed Saturday April 3 2010

Page 32/78 | < Previous Page | 28 29 30 31 32 33 34 35 36 37 38 39  | Next Page >

  • LazyInitializationException when adding to a list that is held within a entity class using hibernate

    - by molleman
    Right so i am working with hibernate gilead and gwt to persist my data on users and files of a website. my users have a list of file locations. i am using annotations to map my classes to the database. i am getting a org.hibernate.LazyInitializationException when i try to add file locations to the list that is held in the user class. this is a method below that is overridden from a external file upload servlet class that i am using. when the file uploads it calls this method. the user1 is loaded from the database elsewhere. the exception occurs at user1.getFileLocations().add(fileLocation); . i dont understand it really at all.! any help would be great. the stack trace of the error is below public String executeAction(HttpServletRequest request, List<FileItem> sessionFiles) throws UploadActionException { for (FileItem item : sessionFiles) { if (false == item.isFormField()) { try { YFUser user1 = (YFUser)getSession().getAttribute(SESSION_USER); // This is the location where a file will be stored String fileLocationString = "/Users/Stefano/Desktop/UploadedFiles/" + user1.getUsername(); File fl = new File(fileLocationString); fl.mkdir(); // so here i will create the a file container for my uploaded file File file = File.createTempFile("upload-", ".bin",fl); // this is where the file is written to disk item.write(file); // the FileLocation object is then created FileLocation fileLocation = new FileLocation(); fileLocation.setLocation(fileLocationString); //test System.out.println("file path = "+file.getPath()); user1.getFileLocations().add(fileLocation); //the line above is where the exception occurs } catch (Exception e) { throw new UploadActionException(e.getMessage()); } } removeSessionFileItems(request); } return null; } //This is the class file for a Your Files User @Entity @Table(name = "yf_user_table") public class YFUser implements Serializable,ILightEntity { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "user_id",nullable = false) private int userId; @Column(name = "username") private String username; @Column(name = "password") private String password; @Column(name = "email") private String email; @ManyToMany(cascade = CascadeType.ALL) @JoinTable(name = "USER_FILELOCATION", joinColumns = { @JoinColumn(name = "user_id") }, inverseJoinColumns = { @JoinColumn(name = "locationId") }) private List<FileLocation> fileLocations = new ArrayList<FileLocation>() ; public YFUser(){ } public int getUserId() { return userId; } private void setUserId(int userId) { this.userId = userId; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public List<FileLocation> getFileLocations() { if(fileLocations ==null){ fileLocations = new ArrayList<FileLocation>(); } return fileLocations; } public void setFileLocations(List<FileLocation> fileLocations) { this.fileLocations = fileLocations; } /* public void addFileLocation(FileLocation location){ fileLocations.add(location); }*/ @Override public void addProxyInformation(String property, Object proxyInfo) { // TODO Auto-generated method stub } @Override public String getDebugString() { // TODO Auto-generated method stub return null; } @Override public Object getProxyInformation(String property) { // TODO Auto-generated method stub return null; } @Override public boolean isInitialized(String property) { // TODO Auto-generated method stub return false; } @Override public void removeProxyInformation(String property) { // TODO Auto-generated method stub } @Override public void setInitialized(String property, boolean initialised) { // TODO Auto-generated method stub } @Override public Object getValue() { // TODO Auto-generated method stub return null; } } @Entity @Table(name = "fileLocationTable") public class FileLocation implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "locationId", updatable = false, nullable = false) private int ieId; @Column (name = "location") private String location; public FileLocation(){ } public int getIeId() { return ieId; } private void setIeId(int ieId) { this.ieId = ieId; } public String getLocation() { return location; } public void setLocation(String location) { this.location = location; } } Apr 2, 2010 11:33:12 PM org.hibernate.LazyInitializationException <init> SEVERE: failed to lazily initialize a collection of role: com.example.client.YFUser.fileLocations, no session or session was closed org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.example.client.YFUser.fileLocations, no session or session was closed at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:380) at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:372) at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:365) at org.hibernate.collection.AbstractPersistentCollection.write(AbstractPersistentCollection.java:205) at org.hibernate.collection.PersistentBag.add(PersistentBag.java:297) at com.example.server.TestServiceImpl.saveFileLocation(TestServiceImpl.java:132) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at net.sf.gilead.gwt.PersistentRemoteService.processCall(PersistentRemoteService.java:174) at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:224) at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62) at javax.servlet.http.HttpServlet.service(HttpServlet.java:713) at javax.servlet.http.HttpServlet.service(HttpServlet.java:806) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362) at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729) at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) at org.mortbay.jetty.Server.handle(Server.java:324) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505) at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647) at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380) at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:396) at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488) Apr 2, 2010 11:33:12 PM net.sf.gilead.core.PersistentBeanManager clonePojo INFO: Third party instance, not cloned : org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.example.client.YFUser.fileLocations, no session or session was closed

    Read the article

  • writing code for nm-alike command [C++]

    - by Neeraj
    Hi everyone! Out of curiosity about reverse engineering, I am thinking of writing a simple program (in C++) that takes an executable as input and produces the names of all the functions that were a part of source program of that executable. Any pointers on how should I go about it? Step-by-step approach would be much appreciated!

    Read the article

  • Return only the new database items since last check in Rails

    - by Smith
    I'm fairly new to Ruby, and currently trying to implement an AJAX style commenting system. When the user views a topic, all the current comments on that topic will be displayed. The user can post a comment on the page of a topic and it should automatically display without having to refresh the page, along with any new comments that have been posted since the last comment currently displayed to the user. The comments should also automatically refresh at a specified frequency. I currently have the following code: views/idea/view.html.erb <%= periodically_call_remote(:update => "div_chat", :frequency => 1, :position => "top", :url => {:controller => "comment", :action => :test_view, :idea_id => @idea.id } ) %> <div id="div_chat"> </div> views/comment/test_view.html.erb <% @comments.each do |c| %><div id="comment"> <%= c.comment %> </div> <% end %> controllers/comment_controller.rb class CommentController < ApplicationController before_filter :start_defs def add_comment @comment = Comment.new params[:comment] if @comment.save flash[:notice] = "Successfully commented." else flash[:notice] = "UnSuccessfully commented." end end def test_render @comments = Comment.find_all_by_idea_id(params[:idea_id], :order => "created_at DESC", :conditions => ["created_at > ?", @latest_time] ) @latest = Comment.find(:first, :order => "created_at DESC") @latest_time = @latest.created_at end def start_defs @latest = Comment.find(:first, :order => "created_at ASC") @latest_time = @latest.created_at end end The problem is that every time periodically_call_remote makes a call, it returns the entire list of comments for that topic. From what I can tell, the @latest_time gets constantly reset to the earliest created_at, rather than staying updated to the latest created_at after the comments have been retrieved. I'm also not sure how I should directly refresh the comments when a comment is posted. Is it possible to force a call to periodically_call_remote on a successful save?

    Read the article

  • how to know the protocol from servlets

    - by Dusk
    If I need to get inbox messages by passing request from servlets to javamail API , how can I know the protocol in which to retrieve inbox messages? Do I have to state the protocol in request URL? I've already checked in gmail, where they haven't stated any protocol, then How can I get inbox messages based on particular protocol like: POP3 or IMAP

    Read the article

  • C code to round numbers

    - by webgenius
    Is there any way to round numbers in C? I do not want to use ceil and floor. Is there any other alternative? I came across this code snippet when I Googled for the answer: (int)(num < 0 ? (num - 0.5) : (num + 0.5)) The above line always prints the value as 4 even when float num =4.9. Please suggest a solution.

    Read the article

  • How can i attached iphone image through MFMailComposerView in iphone

    - by Pugal Devan
    Hi, I am new to iphone development. I have created a button in the view. On clicking the button it loads the photolibrary from the Iphone. Now i want to attached the those selected image through mail. I donno how can i attached the image in MFMailComposerView. How can i achieve this, Here my code is, -(IBAction) Pictures:(id)sender { self.imgpicker = [[UIImagePickerController alloc] init]; self.imgpicker.delegate = self; self.imgpicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; [self presentModalViewController:self.imgpicker animated:YES]; } - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img1 editingInfo:(NSDictionary *)editInfo { [[picker parentViewController] dismissModalViewControllerAnimated:NO]; UIView *view = [[UIView alloc] init]; (This view for displaying the images) **imageview** = [[UIImageView alloc] initWithImage:img1]; [imageview setFrame:CGRectMake(0, 0, 320, 420)]; [self.view addSubview:imageview]; [view release]; UIBarButtonItem *rightbutton = [[UIBarButtonItem alloc] initWithTitle:@"Email" style:UIBarButtonItemStyleBordered target:self action:@selector(rightbutton)]; self.navigationItem.rightBarButtonItem = rightbutton; [rightbutton release]; } -(void) rightbutton { ***[self emailImage:(UIImage *)image]***;(I donno how to pass the image instance to mail view) } - (void)emailImage:(UIImage *)image { picker = [[MFMailComposeViewController alloc] init]; picker.mailComposeDelegate = self; [picker setToRecipients:[NSArray arrayWithObjects:@"[email protected]",nil]]; NSData *data = UIImagePNGRepresentation(image); [picker addAttachmentData:data mimeType:@"image/png" fileName:@"iPod Library Image"]; [self presentModalViewController:picker animated:YES]; [picker release]; } Plese help me out. Thanks.

    Read the article

  • HOWTO - Compare a date string to datetime in SQL Server?

    - by Guy
    In SQL Server I have a DATETIME column which includes a time element. Example: '14 AUG 2008 14:23:019' What is the best method to only select the records for a particular day, ignoring the time part? Example: (Not safe, as it does not match the time part and returns no rows) DECLARE @p_date DATETIME SET @p_date = CONVERT( DATETIME, '14 AUG 2008', 106 ) SELECT * FROM table1 WHERE column_datetime = @p_date Note: Given this site is also about jotting down notes and techniques you pick up and then forget, I'm going to post my own answer to this question as DATETIME stuff in MSSQL is probably the topic I lookup most in SQLBOL. Update Clarified example to be more specific. Edit Sorry, But I've had to down-mod WRONG answers (answers that return wrong results). @Jorrit: WHERE (date>'20080813' AND date<'20080815') will return the 13th and the 14th. @wearejimbo: Close, but no cigar! badge awarded to you. You missed out records written at 14/08/2008 23:59:001 to 23:59:999 (i.e. Less than 1 second before midnight.)

    Read the article

  • Blackberry Application not deploying in simulator from eclipse

    - by Joe
    I wrote a first sample Hello World Program for BB in eclipse using the plugin and everything worked fine. But then I wrote another app, not much different from the first and I went to deploy it and the simulator opened but only the first application was there. I tried loading the .cod file from inside the simulator but that didn't work either. I also tried exiting and resetting the simulator and using the clean.bat file but none of that worked either. Finally I tried to load another sample program I downloaded from RIM and that worked just fine. Help! I'm completely stuck.

    Read the article

  • Unable to detect Capture Device (webcam) through JMF

    - by Padmaja
    Hello, I am using JMF to operate my web cam.My usb webcam works perfectly with JMF, I used it in JMStudio however,when I make this call from my java code deviceListVector = CaptureDeviceManager.getDeviceList( null ); my USB "webcam" is detected however when i am trying to detect webcam on my laptop it is not detecting any device. How can I properly detect the webcam of laptop, and its formats, from JMF API? Please help me. Thanks in advance.

    Read the article

  • stuck on sliders with jquery

    - by chris
    I am building a portfolio page of different work that has been done and im using two different jquery sliding techniques, one nested in amongst the other one. The first slider works great but the second one doesnmt work that great for the first few and then doesnt work at all. If you take a look at this page- You can click the clients up and down the left side to slide the main divs, but when you click on the squares in below the images to slide in and out the content, either it doesnt work as smoothly as it should or it doesnt work right at all. http://justni.com/wip/mdd/martin_duggan_portfolio.html anyone wanna take a look at the code and tell me what am doing wrong?

    Read the article

  • How do I prevent capistrano from overwriting files uploaded by users in their own folders?

    - by Hrishi Mittal
    I'm using Capistrano and git to deploy a RoR app. I have a folder under which each user has their own folder. When a user uploads or saves a file, it is saved in their own folder. When I deploy new versions of the code to the server, the user files and folders are overwritten with what's on my dev machine. Is there a way to ignore some folders in capistrano, like we do in git? This post - http://www.ruby-forum.com/topic/97539 - suggests using symlinks and storing the user files in a shared folder. But it's an old post, so I'm wondering if there is a better way to do it now. Also, does anyone know of any good screencasts/tutorials to recommend for using RoR+git+capistrano? Thanks.

    Read the article

  • Create a overflow screen while a game/program is running?

    - by Dodi300
    Hello. Does anyone know how I can create a screen overflow while a program is running? Mainly while a game is running. If anyone has used xFire or Steam, these use this feature. I've created a winform which starts the game/program and then minimizes. Could the overflow be created in the same winform? Thanks for the help! :)

    Read the article

  • How to set the email protocol in JavaMail

    - by Dusk
    If I need to get inbox messages by passing request from servlets to javamail API , how can I know the protocol in which to retrieve inbox messages? Do I have to state the protocol in request URL? I've already checked in gmail, where they haven't stated any protocol, then How can I get inbox messages based on particular protocol like: POP3 or IMAP

    Read the article

  • Need tutorials on Content providers in android

    - by Rahul Varma
    Hi folks, I am in desperate need of good tutorials on Content Providers in Android. I have been searching in the web for the tutorials but none could give me a clear idea on how content providers work. I'll be grateful if anyone can provide me with sample codes of the projects that implement content providers...

    Read the article

  • Parsing Tabular cell data with space where there is td tag.

    - by Harikrishna
    I am parsing html tabular information with the help of the html agility pack. Now First I am finding the rows in that table like var rows = table.Descendants("tr"); then I find the cell data for each row like foreach(var row in rows) { string rowInnerText = row.InnerText; } That gives me the cell data.But with no spaces between them like NameAdressPhone No but I want the innertext like Name Address Phone No means where there is td tag I want to keep there one space between different column cell.

    Read the article

  • Use WixUIBannerBmp in my custom dialog

    - by leiflundgren
    In my installer I have set WixUIBannerBmp to point to my own custom dialog-banner.bmp. Now I have added a custom dialog I would like to have the same banner as on the other dialogs. Is there a way to refer to the existing WixUIBannerBmp? Workaround would be to create a Binary containing the image and refer to that. But it seems like it shouldn't be needed. /L

    Read the article

  • Problem in named destination

    - by Palanisamy
    hi, i want to give deep linking for named destination.. is that possible? i am using this tool : http://flexpaper.devaldi.com/ This tool is loading PDF from converting PDF to SWF using PDF2SWF(www.swftools.org) is there any way to get the named destination and give deep linking for the named destination..? Please help me. thanks in advance.. Palanisamy

    Read the article

  • How can i attached iphone image through mail in iphone

    - by Pugal Devan
    Hi, I am new to iphone development. I have created a button in the view. On clicking the button it loads the photolibrary from the Iphone. Now i want to attached the those selected image through mail. I donno how to attach the image in MFMailComposerView. How can i achieve this, Here my code is, -(IBAction) Pictures:(id)sender { self.imgpicker = [[UIImagePickerController alloc] init]; self.imgpicker.delegate = self; self.imgpicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; [self presentModalViewController:self.imgpicker animated:YES]; } - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img1 editingInfo:(NSDictionary *)editInfo { [[picker parentViewController] dismissModalViewControllerAnimated:NO]; UIView *view = [[UIView alloc] init]; (This view for displaying the images) imageview = [[UIImageView alloc] initWithImage:img1]; [imageview setFrame:CGRectMake(0, 0, 320, 420)]; [self.view addSubview:imageview]; [view release]; UIBarButtonItem *rightbutton = [[UIBarButtonItem alloc] initWithTitle:@"Email" style:UIBarButtonItemStyleBordered target:self action:@selector(rightbutton)]; self.navigationItem.rightBarButtonItem = rightbutton; [rightbutton release]; } -(void) rightbutton { [self emailImage:(UIImage *)image];( how to pass the image to mail view) } - (void)emailImage:(UIImage *)image { picker = [[MFMailComposeViewController alloc] init]; picker.mailComposeDelegate = self; [picker setToRecipients:[NSArray arrayWithObjects:@"[email protected]",nil]]; NSData *data = UIImagePNGRepresentation(image); [picker addAttachmentData:data mimeType:@"image/png" fileName:@"iPod Library Image"]; [self presentModalViewController:picker animated:YES]; [picker release]; } Please help me out. Thanks.

    Read the article

  • Why does my entire page reload in Chrome and Firefox when using asynchronous UpdatePanel postbacks?

    - by Alex
    Being a bit perplexed about this issue by now, I hope some of you gurus can shed some light on my problem... I've developed a AJAX-enhanced website, which has been running fine in IE, Chrome and Firefox for a year or so. I use a Timer-control to check for incoming messages every 30 seconds, and this updates an UpdatePanel showing potential new messages. Now several one of my Firefox users complain about the page refreshing every 30 seconds! I my self cannot reproduce this behaviour, but given the "30 seconds"-description, I cursed my Timer-solution as the culprit. But now, I'm experiencing this error myself, not in Firefox though, but in Google Chrome! (And only on one of my two computers!) Every 30 seconds the page reloads! But I found that it's not only related to the Timer, because all other asynchronous postbacks to the server within UpdatePanels reloads the entire page as well. This error has never been experienced in Internet Explorer (to my knowledge). As I said, this it not only related to the Timer postback, but if it's of interest to anybody the code is like this: <asp:Timer runat="server" ID="MailCheckTimer" Interval="30000" OnTick="MailChecker_Tick"></asp:Timer> <asp:UpdatePanel runat="server" ID="MailCheckerUpdatePanel" UpdateMode="Conditional"> <ContentTemplate> <div class="newmail_box" runat="server" id="newmail_box"> <!-- Content stripped for this example --> </div> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="MailCheckTimer" /> </Triggers> </asp:UpdatePanel> In other places of the website I call the client side __doPostBack function directly from JavaScript in relation to an UpdatePanel. Normal behaviour for this call is to updated the referenced UpdatePanel with some content, but now in Chrome this refreshes the entire page! (but again not consistently, and never in IE) Even the most fundamental UpdatePanel operations like refreshing the content after a button (inside the panel) is clicked, forces the page to reload completely: <asp:Button ID="btnSearch" runat="server" Text="Search" OnClick="btnSearch_Click"></asp:Button> And just to torment me further, I only experience this on my public website, and not in my local development environment, making it a tedious affair for me to find the actual cause! :( Any ideas on why this happens? Why so inconsistently? Has it to do with my UpdatePanel-design? Or does some security setting in Firefox/Chrome that prevent some asynchronous UpdatePanel callbacks? Any help or idea is highly appreciated!

    Read the article

  • NHibernate: how to do lookup a specific date

    - by Daoming Yang
    How I can lookup a specific date in Nhibernate? I'm currently using this to lookup one day's order. ICriteria criteria = SessionManager.CurrentSession.CreateCriteria(typeof(Order)) .Add(Expression.Between("DateCreated", date.Date.AddDays(-1), date.Date.AddDays(1))) .AddOrder(NHibernate.Criterion.Order.Desc("OrderID")); I tried the following code, but they did bring the data for me. Expression.Eq("DateCreated", date) Expression.Like("DateCreated", date) Note: The pass in date value will be like this 2010-04-03 00:00:00, The actual date value in the database will be like this 2010-03-13 11:17:16.000 Can anyone let me know how to do this? Many thanks.

    Read the article

  • struts 2 bean is not created

    - by Dewfy
    Hello colleagues! At first some precondition to my question, I'm using struts2 + tiles2 + toplink. NO spring at all. The simplest scenario - is to display list of entities on the page. To optimize resolving JPA's EntityManager I would like to create helper (JPAResourceBean) that implements lazy load of entity manager. For this purposes I'm going to use struts2's bean declaration: <bean name="myfactory" class="my.model.JPAResourceBean" scope="session" optional="false"/> Why bean is not instantiated neither in session? (I'm using s:property just for debug) ... <s:property value="#session.myfactory" default="buka.1"/> ... nor in plain bean list: ... <s:property value="#myfactory" default="buka.2"/> ... May be the second part of question is - how to resolve this bean from java code?

    Read the article

  • How to check if a Statistics is auto-created in a SQL Server 2000 DB using T-SQL?

    - by The Shaper
    Hi all. A while back I had to come up with a way to clean up all indexes and user-created statistics from some tables in a SQL Server 2005 database. After a few attempts it worked, but now I gotta have it working in SQL Server 2000 databases as well. For SQL Server 2005, I used SELECT Name FROM sys.stats WHERE object_id = object_id(@tableName) AND auto_created = 0 to fetch Statistics that were user-created. However, SQL 2000 doesn't have a sys.stats table. I managed to fetch the indexes and statistics in a distinguishable way from the sysindexes table, but I just couldn't figure out what the sys.stats.auto_created match is for SQL 2000. Any pointers? BTW: T-SQL please.

    Read the article

  • CSS Font Border ?

    - by Lars Tackmann
    With all the new CSS3 border stuff going on (-webkit...) is it now possible to add a border to your font ? (like the solid white border around the blue Twitter logo). If not, are there any not-to-ugly hacks that will accomplish this in CSS/XHTML or do I still need to fire up Photoshop

    Read the article

< Previous Page | 28 29 30 31 32 33 34 35 36 37 38 39  | Next Page >