Search Results

Search found 1098 results on 44 pages for 'persistence'.

Page 6/44 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • Persistance Queue Implementation

    - by Winter
    I was reading an article on Batch Processing in java over at JDJ http://java.sys-con.com/node/415321 . The article mentioned using a persistence queue as a Batch Updater instead of immediately sending an individual insert or update to the database. The author doesn't give a concrete example of this concept so I googled Persistence Queue but that didn't come up with much. Does anyone know of a good example of this?

    Read the article

  • JAVA: how to load database url from web.xml?

    - by user357255
    I'm using persistence API and want to load jdbc URL from web.xml. URL should be a context parameter of servlet. I can't find how to construct EntityManagerFactory not using persistence.xml. May be I should create PersistenceUnit in servlet and set some parameters? Can you give me some short example? Thank you

    Read the article

  • JPA - Performance with using multiple entity manager

    - by Nguyen Tuan Linh
    My situation is: The code is not mine I have two kinds of database: one is Dad, one is Son. In Dad, I have a table to store JNDI name. I will look up Dad using JNDI, create entity manager, and retrieve this table. From these retrieved JNDI names, I will create multiple entity managers using multiple Son databases. The problem is: Son have thousands of entities. It takes each Son database around 10 minutes to load all entities. If there is 4 Son databases, it will be 40 minutes. My question: Is there any way to load all entities and use them for all entity manager? Please look at the code below For each Son JNDI: Map<String, String> puSonProperties = new HashMap<String, String>(); puSonProperties.put("javax.persistence.jtaDataSource", sonJndi); EntityManagerFactory emf = Persistence.createEntityManagerFactory("PUSon", puSonProperties); PUSon - All of them use the same persistence unit log.info("Verify entity manager for son: {0} - {1}", sonCode, emSon.find(Son_configuration.class, 0) != null ? "ok" : "failed!"); This is the actual code where the loading of all entities begins. 10 mins.

    Read the article

  • Having an issue with Onejar-Maven-Plugin

    - by reverendgreen
    I am trying to package a simple maven java project (uses javax.persistence api) into a single jar using the onejar-maven-plugin. I can run the program fine in eclipse; however when execute the onejar I get the exception below. If someone could provide some insight, that would be appreciated. Thanks, RG Exception in thread "main" java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.simontuffs.onejar.Boot.run(Boot.java:306) at com.simontuffs.onejar.Boot.main(Boot.java:159) Caused by: Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.PersistenceUnitLoadingExcept Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: com.simontuffs.onejar.JarClassLoader@190d11 Internal Exception: java.lang.ClassCastException: sun.misc.Launcher$AppClassLoader cannot be cast to com.simontuffs.onejar.JarClassLoader at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:126 at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:133) at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:65) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:78) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54) at com.test.onejartest.App.main(App.java:19) ... 6 more Caused by: java.lang.ClassCastException: sun.misc.Launcher$AppClassLoader cannot be cast to com.simontuffs.onejar.JarClassLoader at com.simontuffs.onejar.JarClassLoader.getByteStream(JarClassLoader.java:753) at com.simontuffs.onejar.Handler$1.getInputStream(Handler.java:50) at java.net.URL.openStream(Unknown Source) at org.eclipse.persistence.internal.jpa.deployment.ArchiveFactoryImpl.isJarInputStream(ArchiveFactoryImpl.java:124) at org.eclipse.persistence.internal.jpa.deployment.ArchiveFactoryImpl.createArchive(ArchiveFactoryImpl.java:106) at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.findPersistenceArchives(PersistenceUnitProcessor.java:213) at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.findPersistenceUnitInfoInArchives(JPAInitializer.java:134) at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.findPersistenceUnitInfo(JPAInitializer.java:125) at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:98) ... 10 more pom.xml: ... <pluginRepositories> <pluginRepository> <id>onejar-maven-plugin.googlecode.com</id> <url>http://onejar-maven-plugin.googlecode.com/svn/mavenrepo</url> </pluginRepository> </pluginRepositories> ... <build> <plugins> <plugin> <groupId>org.dstovall</groupId> <artifactId>onejar-maven-plugin</artifactId> <version>1.3.0</version> <executions> <execution> <configuration> <mainClass>com.test.onejartest.App</mainClass> </configuration> <goals> <goal>one-jar</goal> </goals> </execution> </executions> </plugin> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.1</version> <configuration> <target>1.6</target> <source>1.6</source> </configuration> </plugin> </plugins> </build> ... <dependencies> <dependency> <groupId>javax.persistence</groupId> <artifactId>persistence-api</artifactId> <version>2.0.0</version> </dependency> <dependency> <groupId>org.eclipse.persistence</groupId> <artifactId>eclipselink</artifactId> <version>2.0.0</version> </dependency> <dependency> <groupId>com.microsoft.sqlserver.jdbc</groupId> <artifactId>sqljdbc</artifactId> <version>4.0.0</version> </dependency> </dependencies>

    Read the article

  • JPA Entity (in multiple persistence-unit) in OSGi (Spring DM) Environnement is confusing me.

    - by Vincent Demeester
    Hi, I'm a bit confused about a strange behavior of my JPA's related objects. I have three bundle : The User bundle does contain some user-related objects, but mainly the User object. The Energy bundle does contain some energy-related objects, and particularly a ConsumptionTerminal which contains a List of User. The Index bundle does contain an Index object that has no dependency at all. My OSGi environment is the following : A DataSource bundle that provide 2 services : dataSource and jpaVendorAdapter. The three bundles. They consume dataSource and jpaVendorAdapter. Their module-context.xml file look like : And they all have a persistence.xml file : User <?xml version="1.0" encoding="UTF-8"?> <persistence> <persistence-unit name="securityPU" transaction-type="JTA"> <jta-data-source>java:/securityDataSourceService</jta-data-source> <class>net.nextep.amundsen.security.domain.User</class> <!-- [...] --> <exclude-unlisted-classes>true</exclude-unlisted-classes> <properties> <property name="eclipselink.logging.level" value="INFO" /> <property name="eclipselink.ddl-generation" value="create-tables" /> <property name="eclipselink.ddl-generation.output-mode" value="database" /> <property name="eclipselink.orm.throw.exceptions" value="true" /> </properties> </persistence-unit> </persistence> Energy <?xml version="1.0" encoding="UTF-8"?> <persistence> <persistence-unit name="energyPU" transaction-type="JTA"> <jta-data-source>java:/securityDataSourceService</jta-data-source> <class>net.nextep.amundsen.security.domain.User</class> <class>net.nextep.amundsen.energy.domain.User</class> <!-- [...] --> <exclude-unlisted-classes>true</exclude-unlisted-classes> <properties> <property name="eclipselink.logging.level" value="INFO" /> <property name="eclipselink.ddl-generation" value="create-tables" /> <property name="eclipselink.ddl-generation.output-mode" value="database" /> <property name="eclipselink.orm.throw.exceptions" value="true" /> </properties> </persistence-unit> </persistence> Index : This one has the most simple persistence.xml with just the Index class (no shared Class). I'm using named @PersistenceUnit annotation like @PersitenceUnit(name = 'securityPU') (for the User bundle). And finally, I'm using EclipseLink as Jpa provider and Spring DM (+ Spring DM Server in the development process) The problem is the following : When the User bundle is deployed, I'm able to persist User objects. When the User bundle and Energy bundles are both deployed, I'm not able to persist User objects (neither the Energy object). But I don't have any exception at all ! There is no problem at all with the Index bundle. The bug is dataSource independent (I tried with PostgreSQL and MySQL so far). My first conclusion was that the <class>net.nextep.amundsen.security.domain.User</class> in both persistence unit was causing the trouble. I tried without it (and hiding the User dependent object in the Energy bundle) but it failed too. I'm a bit confused about that bug. I'm also not quite sure about the transaction management in this context. I wasn't the one who designed this architecture (but I tell my intern OK without testing it.. shame on me) but if I could understand this bug and maybe fix it without rewrite the bundle (and break my intern work), I would appreciate. Am I doing something wrong ? (it's obvious, but what..) Did I miss something while reading documentation ? By the way, I'm also looking for some best practices or advices when it comes to JPA, EclipseLink (or whatever JPA Provider) and Spring DM (and OSGi in general). I found interesting slides from Mike Keith about this topic (by browsing Stackoverflow).

    Read the article

  • Detach an entity from a JPA persistence context (JPA 2.0 / Hibernate / EJB 3 / J2EE 6)

    - by Julien
    Hi, I wrote a stateless EJB method allowing to get an entity in "read-only" mode. The way to do this is to get the entity with the EntityManager then detach it (using the JPA 2.0 EntityManager). My code is the following: @PersistenceContext private EntityManager entityManager; public T getEntity(int entityId, Class<T> specificClass, boolean readOnly) throws Exception{ try{ T entity = (T)entityManager.find(specificClass, entityId); if (readOnly){ entityManager.detach(entity); } return entity; }catch (Exception e){ logger.error("", e); throw e; } } Getting the entity works fine, but the call to the detach method returns the following error: GRAVE: javax.ejb.EJBException at ... Caused by: java.lang.AbstractMethodError: org.hibernate.ejb.EntityManagerImpl.detach(Ljava/lang/Object;)V at com.sun.enterprise.container.common.impl.EntityManagerWrapper.detach(EntityManagerWrapper.java:973) at com.mycomp.dal.MyEJB.getEntity(MyEJB.java:37) I can't get more information and don't understand what the problem is... Could somebody help ?

    Read the article

  • sharp architecture, FluentNHibernate, automapper, DTO, 1:m persistence question

    - by csetzkorn
    Let us say we have a class A which has a reference to another class B (1:m) public class A { public virtual B B { get; set; } } I reflect this using FluentNHibernate within the sharp architecture and also manage to ‘initialise’ A and its B via a DTO and Automapper. The DTO contain A’s values and B (just B’s id value/A’s foreign key initialised). I was hoping that I can persist A by ‘just’ using its 'out of the box repository' without requiring B’s repository using: SaveOrUpdate(A); (A has been mapped using AutoMapper and contains B with its Id initialised) Was my assumption too naive? Can I achieve this somehow (without ever requiring B’s repository)? Or do I have to use A’s and B’s repository in, for example, the controller or some other service layer? Thanks. Best wishes, Christian

    Read the article

  • Changes in gcc/persistence of optimization flags gcc/C

    - by gnometorule
    Just curious. Using gcc/gdb under Ubuntu 9.10. Reading a C book that also often gives the disassembly of the object file. When reading in January, my disassembly looks a lot like the book's; now, it's quite different - possibly more optimized (I notice some re-arrangements in the assembly code now that, at least in the files I checked, look optimized). I have used optimization options -O1 - -O3 for gcc between the first and second read, but not before the first. (1) Is the use of optimization options persistent, aka, if you use them once, you'll use them until switching them off? That would be weird (browsed man file and at least did not see anything to that sort). In the unlikely case that it is true, how do you switch them off? (2) Has gcc's assembly changed through any recent upgrade? (3) Does gcc sometimes produce (significantly) different assembly code although same compile options are chosen? Thanks much.

    Read the article

  • PERSISTENCE LOB WITH JPA

    - by rfders
    Hi, Folks. I have this problem using JBOSS, EJB3 and MSSQL Express . i'm trying to persist an entity with an Blob attribute which was converted into a byte[], apparently it create the entity perfectly, no error was logged at jboss's console. but when i check into database the column is null. i already checked the Object to byte[] method and it is fine. i tried assigning Image and varbinary(Max) data type to this column. so i really don't know what it happening, why the column is not inserted into database. thanks a lot.

    Read the article

  • Optimal storage of data structure for fast lookup and persistence

    - by Mikael Svenson
    Scenario I have the following methods: public void AddItemSecurity(int itemId, int[] userIds) public int[] GetValidItemIds(int userId) Initially I'm thinking storage on the form: itemId -> userId, userId, userId and userId -> itemId, itemId, itemId AddItemSecurity is based on how I get data from a third party API, GetValidItemIds is how I want to use it at runtime. There are potentially 2000 users and 10 million items. Item id's are on the form: 2007123456, 2010001234 (10 digits where first four represent the year). AddItemSecurity does not have to perform super fast, but GetValidIds needs to be subsecond. Also, if there is an update on an existing itemId I need to remove that itemId for users no longer in the list. I'm trying to think about how I should store this in an optimal fashion. Preferably on disk (with caching), but I want the code maintainable and clean. If the item id's had started at 0, I thought about creating a byte array the length of MaxItemId / 8 for each user, and set a true/false bit if the item was present or not. That would limit the array length to little over 1mb per user and give fast lookups as well as an easy way to update the list per user. By persisting this as Memory Mapped Files with the .Net 4 framework I think I would get decent caching as well (if the machine has enough RAM) without implementing caching logic myself. Parsing the id, stripping out the year, and store an array per year could be a solution. The ItemId - UserId[] list can be serialized directly to disk and read/write with a normal FileStream in order to persist the list and diff it when there are changes. Each time a new user is added all the lists have to updated as well, but this can be done nightly. Question Should I continue to try out this approach, or are there other paths which should be explored as well? I'm thinking SQL server will not perform fast enough, and it would give an overhead (at least if it's hosted on a different server), but my assumptions might be wrong. Any thought or insights on the matter is appreciated. And I want to try to solve it without adding too much hardware :) [Update 2010-03-31] I have now tested with SQL server 2008 under the following conditions. Table with two columns (userid,itemid) both are Int Clustered index on the two columns Added ~800.000 items for 180 users - Total of 144 million rows Allocated 4gb ram for SQL server Dual Core 2.66ghz laptop SSD disk Use a SqlDataReader to read all itemid's into a List Loop over all users If I run one thread it averages on 0.2 seconds. When I add a second thread it goes up to 0.4 seconds, which is still ok. From there on the results are decreasing. Adding a third thread brings alot of the queries up to 2 seonds. A forth thread, up to 4 seconds, a fifth spikes some of the queries up to 50 seconds. The CPU is roofing while this is going on, even on one thread. My test app takes some due to the speedy loop, and sql the rest. Which leads me to the conclusion that it won't scale very well. At least not on my tested hardware. Are there ways to optimize the database, say storing an array of int's per user instead of one record per item. But this makes it harder to remove items.

    Read the article

  • Session persistence problem

    - by YsoL8
    Hello I'm having a problem with getting sessions to persist, and having no luck searching, I need to ask. I can access the contents of my session as expected when first set, but as soon as the page refreshes I lose everything and I don't see why. session_start() is set and I'm not unseting or destroying anything. I looked at PHP Info under sessions and everything looks ok (but my understanding of sessions is limited). I'm running MAMP on OS 10.5, and the last time I used sessions they worked.

    Read the article

  • JPA One To Many Relationship Persistence Bug

    - by Brian
    Hey folks, I've got a really weird problem with a bi-directional relationship in jpa (hibernate implementation). A User is based in one Region, and a Region can contain many Users. So...relationship is as follows: Region object: @OneToMany(mappedBy = "region", fetch = FetchType.LAZY, cascade = CascadeType.ALL) public Set<User> getUsers() { return users; } public void setUsers(Set<User> users) { this.users = users; } User object: @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER) @JoinColumn(name = "region_fk") public Region getRegion() { return region; } public void setRegion(Region region) { this.region = region; } So, the relationship as you can see above is Lazy on the region side, ie, I don't want the region to eager load all the users. Therefore, I have the following code within my DAO layer to add a user to an existing user to an existing region object... public User setRegionForUser(String username, Long regionId){ Region r = (Region) this.get(Region.class, regionId); User u = (User) this.get(User.class, username); u.setRegion(r); Set<User> users = r.getUsers(); users.add(u); System.out.println("The number of users in the set is: "+users.size()); r.setUsers(users); this.update(r); return (User)this.update(u); } The problem is, when I run a little unit test to add 5 users to my region object, I see that the region.getUsers() set always stays stuck at 1 object...somehow the set isn't getting added to. My unit test code is as follows: public void setUp(){ System.out.println("calling setup method"); Region r = (Region)ManagerFactory.getCountryAndRegionManager().get(Region.class, Long.valueOf("2")); for(int i = 0; i<loop; i++){ User u = new User(); u.setUsername("username_"+i); ManagerFactory.getUserManager().update(u); ManagerFactory.getUserManager().setRegionForUser("username_"+i, Long.valueOf("2")); } } public void tearDown(){ System.out.println("calling teardown method"); for(int i = 0; i<loop; i++){ ManagerFactory.getUserManager().deleteUser("username_"+i); } } public void testGetUsersForRegion(){ Set<User> totalUsers = ManagerFactory.getCountryAndRegionManager().getUsersInRegion(Long.valueOf("2")); System.out.println("Expecting 5, got: "+totalUsers.size()); this.assertEquals(5, totalUsers.size()); } So the test keeps failing saying there is only 1 user instead of the expected 5. Any ideas what I'm doing wrong? thanks very much, Brian

    Read the article

  • Unit of Work pattern and persistence

    - by Mosh
    Hello, I have been reading about Unit of Work pattern but I am confused about how the UoW actually persists data. When we commit the changes, UoW should iterate through the list of Added, Updated and Deleted objects and somehow find a class responsible to Add, Update, Delete objects of a certain type. I couldn't find an example showing this technique. Any advice on this would be greatly appreciated. Mosh

    Read the article

  • Domain model: should things like Logging, Audit, Persistence be in it

    - by hom.tanks
    I'm having a hard time convincing our architect that a Domain model should only have the essential elements of the business domain on it. Things like the fact that a class is persistable, that it needs logging and auditing and that it has a RESTful URI should not drive the domain model. They can be added later on, by using interfaces. Ours is a healthcare information management system. At the very coarse level, its a system where users login and access their healthcare information. They can share this information with others and be custodian for others' information (think Roles). But because of a few sound bytes that caught on early like "Everything should be a REST resource" the model now has a top level class called Resource that every other class extends from. I'm trying to make him see that the domain model should have well defined concepts like User Account, HealthDocument, UserRole etc which are distinct entities of the business , with specific associations between them. Clubbing everything under Resource class lets our model be inflexible besides being potentially incorrect. But he wants me to show him why its a bad idea to do it his way. I don't know how to articulate that properly but all my OO instincts tell me that its just not right. Any thoughts?

    Read the article

  • Persistence of texture parameters

    - by fen
    I use glBindTexture() to bind a previously created texture. After the glBindTexture() call I use glTexParameteri() to set MIN and MAG filter. No problem so far. Are those parameters I set using glTexParameteri() bound to the texture itself or are they lost if I bind another texture. Do i have to set them again? glGenTexture(1, &tex1); glGenTexture(1, &tex2); /* bind tex1 and set params */ glBindtexture(GL_TEXTURE_RECTANGLE_ARB, tex1); glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, ...); glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR); /* do something */ /* bind tex2 and set params */ glBindtexture(GL_TEXTURE_RECTANGLE_ARB, tex2); glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, ...); glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR); /* do something */ /* bind tex1 again */ glBindtexture(GL_TEXTURE_RECTANGLE_ARB, tex1); /* do i have to set the parameters from above again or are they stored with tex1? */

    Read the article

  • JPA and PostqreSQL: long string persistence

    - by emanemos
    Can anybody tell me how to persist long text using JPA (I use PostgreSQL)? Here's the way I defined a very long string in my class: @Lob private String body; However, this produces a field of type charactervarying(255) in the database. Furthermore, I've tried to use @Column annotation: @Column(columnDefinition="TEXT") private String body; But everything in vain. I would be gratefull for a helpfull comment on this problem.

    Read the article

  • Raising events and object persistence in Django

    - by Mridang Agarwalla
    Hi, I have a tricky Django problem which didn't occur to me when I was developing it. My Django application allows a user to sign up and store his login credentials for a sites. The Django application basically allows the user to search this other site (by scraping content off it) and returns the result to the user. For each query, it does a couple of queries of the other site. This seemed to work fine but sometimes, the other site slaps me with a CAPTCHA. I've written the code to get the CAPTCHA image and I need to return this to the user so he can type it in but I don't know how. My search request (the query, the username and the password) in my Django application gets passed to a view which in turn calls the backend that does the scraping/search. When a CAPTCHA is detected, I'd like to raise a client side event or something on those lines and display the CAPTCHA to the user and wait for the user's input so that I can resume my search. I would somehow need to persist my backend object between calls. I've tried pickling it but it doesn't work because I get the Can't pickle 'lock' object error. I don't know to implement this though. Any help/ideas? Thanks a ton.

    Read the article

  • Persistence store in blackberry

    - by arunabha
    i am trying to save a simple string value "1".If i go back from one screen to another,its saving,but when i exit the app,and start again,i dont see that value being saved.I am implementing persistable interface.Can anyone suggest me where i am getting wrong import net.rim.device.api.util.Persistable; import net.rim.device.api.system.PersistentObject; import net.rim.device.api.system.PersistentStore; public class Persist implements Persistable { public static PersistentObject abc; public static String b; static { abc = PersistentStore.getPersistentObject(0xb92c8fe20b256b82L); } public static void data(){ synchronized (abc) { abc.setContents(1+""); abc.commit(); } } public static String getCurrQuestionNumber() { synchronized (abc) { System.out.println("new title is"+b); b= (String)abc.getContents(); System.out.println("title is"+b); return b; } } }

    Read the article

  • Spring import runs hibernate persistence twice

    - by Jaanus
    I have 2 spring configurations : spring-servlet.xml spring-security.xml needed to add this line to security: <beans:import resource="spring-servlet.xml"/> Now hibernate is ran twice, this is log screenshot : my web.xml: <servlet> <servlet-name>spring</servlet-name> <servlet-class> org.springframework.web.servlet.DispatcherServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>spring</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> <context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/spring-security.xml </param-value> </context-param>

    Read the article

  • Persistence scheme & state data for low memory situations (iphone)

    - by Robin Jamieson
    What happens to state information held by a class's variable after coming back from a low memory situation? I know that views will get unloaded and then reloaded later but what about some ancillary classes & data held in them that's used by the controller that launched the view? Sample scenario in question: @interface MyCustomController: UIViewController { ServiceAuthenticator *authenticator; } -(id)initWithAuthenticator:(ServiceAuthenticator *)auth; // the user may press a button that will cause the authenticator // to post some data to the service. -(IBAction)doStuffButtonPressed:(id)sender; @end @interface ServiceAuthenticator { BOOL hasValidCredentials; // YES if user's credentials have been validated NSString *username; NSString *password; // password is not stored in plain text } -(id)initWithUserCredentials:(NSString *)username password:(NSString *)aPassword; -(void)postData:(NSString *)data; @end The app delegate creates the ServiceAuthenticator class with some user data (read from plist file) and the class logs the user with the remote service. inside MyAppDelegate's applicationDidFinishLaunching: - (void)applicationDidFinishLaunching:(UIApplication *)application { ServiceAuthenticator *auth = [[ServiceAuthenticator alloc] initWithUserCredentials:username password:userPassword]; MyCustomController *controller = [[MyCustomController alloc] initWithNibName:...]; controller.authenticator = auth; // Configure and show the window [window addSubview:..]; // make everything visible [window makeKeyAndVisible]; } Then whenever the user presses a certain button, 'MyCustomController's doStuffButtonPressed' is invoked. -(IBAction)doStuffButtonPressed:(id)sender { [authenticator postData:someDataFromSender]; } The authenticator in-turn checks to if the user is logged in (BOOL variable indicates login state) and if so, exchanges data with the remote service. The ServiceAuthenticator is the kind of class that validates the user's credentials only once and all subsequent calls to the object will be to postData. Once a low memory scenario occurs and the associated nib & MyCustomController will get unloaded -- when it's reloaded, what's the process for resetting up the 'ServiceAuthenticator' class & its former state? I'm periodically persisting all of the data in my actual model classes. Should I consider also persisting the state data in these utility style classes? Is that the pattern to follow?

    Read the article

  • Remote Seam Persistence

    Hi. I have a button in a .xhtml file which calls a javascript function which calls a java function remotely (in jboss seam environment). That java function has an entityManager.persist(object). Do you know why this line of code doesn't commit to the DB? It says something that a transaction hasn't started. I supose in a remote context i don't have a transaction began because if i put an action on that button which calls the same java function instead of using javascript is above, it works fine; entityManager persists the object and i can see it in the DB. Does anyone has any ideas how could i make to actually persist the object using javascript to call the java function? (i have to use javascript because i need the callback function )

    Read the article

  • Hibernate Persistence problems with Bean Mapping (Dozer)

    - by BuffaloBuffalo
    I am using Hibernate 3, and having a particular issue when persisting a new Entity which has an association with an existing detached entity. Easiest way to explain this is via code samples. I have two entities, FooEntity and BarEntity, of which a BarEntity can be associated with many FooEntity: @Entity public class FooEntity implements Foo{ @Id private Long id; @ManyToOne(targetEntity = BarEntity.class) @JoinColumn(name = "bar_id", referencedColumnName = "id") @Cascade(value={CascadeType.ALL}) private Bar bar; } @Entity public class BarEntity implements Bar{ @Id private Long id; @OneToMany(mappedBy = "bar", targetEntity = FooEntity.class) private Set<Foo> foos; } Foo and Bar are interfaces that loosely define getters for the various fields. There are corresponding FooImpl and BarImpl classes that are essentially just the entity objects without the annotations. What I am trying to do is construct a new instance of FooImpl, and persist it after setting a number of fields. The new Foo instance will have its 'bar' member set to an existing Bar (runtime being a BarEntity) from the database (retrieved via session.get(..)). After the FooImpl has all of its properties set, Apache Dozer is used to map between the 'domain' object FooImpl and the Entity FooEntity. What Dozer is doing in the background is instantiating a new FooEntity and setting all of the matching fields. BarEntity is cloned as well via instantiation and set the FooEntity's 'bar' member. After this occurs, passing the new FooEntity object to persist. This throws the exception: org.hibernate.PersistentObjectException: detached entity passed to persist: com.company.entity.BarEntity Below is in code the steps that are occurring FooImpl foo = new FooImpl(); //returns at runtime a persistent BarEntity through session.get() Bar bar = BarService.getBar(1L); foo.setBar(bar); ... //This constructs a new instance of FooEntity, with a member 'bar' which itself is a new instance that is detached) FooEntity entityToPersist = dozerMapper.map(foo, FooEntity.class); ... session.persist(entityToPersist); I have been able to resolve this issue by either removing or changing the @Cascade annotation, but that limits future use for say adding a new Foo with a new Bar attached to it already. Is there some solution here I am missing? I would be surprised if this issue hasn't been solved somewhere before, either by altering how Dozer Maps the children of Foo or how Hibernate reacts to a detached Child Entity.

    Read the article

  • Wanted: Good examples of Scala database persistence

    - by Rydell
    I'm would like to use Scala to persist data to a relational database, so what I am looking for are examples of CRUD operations using Scala. I would like to code on a lower level of abstraction than an ORM like Hibernate/Toplink (read:JDBC), but between us, I would like to see examples of all types. Thanks folks.

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >