Search Results

Search found 18361 results on 735 pages for 'hibernate search'.

Page 78/735 | < Previous Page | 74 75 76 77 78 79 80 81 82 83 84 85  | Next Page >

  • MySQL search for user and their roles

    - by Jenkz
    I am re-writing the SQL which lets a user search for any other user on our site and also shows their roles. An an example, roles can be "Writer", "Editor", "Publisher". Each role links a User to a Publication. Users can take multiple roles within multiple publications. Example table setup: "users" : user_id, firstname, lastname "publications" : publication_id, name "link_writers" : user_id, publication_id "link_editors" : user_id, publication_id Current psuedo SQL: SELECT * FROM ( (SELECT user_id FROM users WHERE firstname LIKE '%Jenkz%') UNION (SELECT user_id FROM users WHERE lastname LIKE '%Jenkz%') ) AS dt JOIN (ROLES STATEMENT) AS roles ON roles.user_id = dt.user_id At the moment my roles statement is: SELECT dt2.user_id, dt2.publication_id, dt.role FROM ( (SELECT 'writer' AS role, link_writers.user_id, link_writers.publication_id FROM link_writers) UNION (SELECT 'editor' AS role, link_editors.user_id, link_editors.publication_id FROM link_editors) ) AS dt2 The reason for wrapping the roles statement in UNION clauses is that some roles are more complex and require a table join to find the publication_id and user_id. As an example "publishers" might be linked accross two tables "link_publishers": user_id, publisher_group_id "link_publisher_groups": publisher_group_id, publication_id So in that instance, the query forming part of my UNION would be: SELECT 'publisher' AS role, link_publishers.user_id, link_publisher_groups.publication_id FROM link_publishers JOIN link_publisher_groups ON lpg.group_id = lp.group_id I'm pretty confident that my table setup is good (I was warned off the one-table-for-all system when researching the layout). My problem is that there are now 100,000 rows in the users table and upto 70,000 rows in each of the link tables. Initial lookup in the users table is fast, but the joining really slows things down. How can I only join on the relevant roles? -------------------------- EDIT ---------------------------------- Explain above (open in a new window to see full resolution). The bottom bit in red, is the "WHERE firstname LIKE '%Jenkz%'" the third row searches WHERE CONCAT(firstname, ' ', lastname) LIKE '%Jenkz%'. Hence the large row count, but I think this is unavoidable, unless there is a way to put an index accross concatenated fields? The green bit at the top just shows the total rows scanned from the ROLES STATEMENT. You can then see each individual UNION clause (#6 - #12) which all show a large number of rows. Some of the indexes are normal, some are unique. It seems that MySQL isn't optimizing to use the dt.user_id as a comparison for the internal of the UNION statements. Is there any way to force this behaviour? Please note that my real setup is not publications and writers but "webmasters", "players", "teams" etc.

    Read the article

  • Finding good heuristic for A* search

    - by Martin
    I'm trying to find the optimal solution for a little puzzle game called Twiddle (an applet with the game can be found here). The game has a 3x3 matrix with the number from 1 to 9. The goal is to bring the numbers in the correct order using the minimum amount of moves. In each move you can rotate a 2x2 square either clockwise or counterclockwise. I.e. if you have this state 6 3 9 8 7 5 1 2 4 and you rotate the upper left 2x2 square clockwise you get 8 6 9 7 3 5 1 2 4 I'm using a A* search to find the optimal solution. My f() is simply the number of rotations need. My heuristic function already leads to the optimal solution but I don't think it's the best one you can find. My current heuristic takes each corner, looks at the number at the corner and calculates the manhatten distance to the position this number will have in the solved state (which gives me the number of rotation needed to bring the number to this postion) and sums all these values. I.e. You take the above example: 6 3 9 8 7 5 1 2 4 and this end state 1 2 3 4 5 6 7 8 9 then the heuristic does the following 6 is currently at index 0 and should by at index 5: 3 rotations needed 9 is currently at index 2 and should by at index 8: 2 rotations needed 1 is currently at index 6 and should by at index 0: 2 rotations needed 4 is currently at index 8 and should by at index 3: 3 rotations needed h = 3 + 2 + 2 + 3 = 10 But there is the problem, that you rotate 4 elements at once. So there a rare cases where you can do two (ore more) of theses estimated rotations in one move. This means theses heuristic overestimates the distance to the solution. My current workaround is, to simply excluded one of the corners from the calculation which solves this problem at least for my test-cases. I've done no research if really solves the problem or if this heuristic still overestimates in same edge-cases. So my question is: What is the best heuristic you can come up with? (Disclaimer: This is for a university project, so this is a bit of homework. But I'm free to use any resource if can come up with, so it's okay to ask you guys. Also I will credit Stackoverflow for helping me ;) )

    Read the article

  • Wordpress Search Results in Order

    - by Brad Houston
    One of my clients websites, www.kevinsplants.co.uk is not showing the search results in alphabetical order, how do I go about ordering the results in alphabetical order? We are using the Shopp plugin and I believe its that plugin that is generating the results! Cheers, Brad case "orderby-list": if (isset($Shopp->Category->controls)) return false; if (isset($Shopp->Category->smart)) return false; $menuoptions = Category::sortoptions(); $title = ""; $string = ""; $default = $Shopp->Settings->get('default_product_order'); if (empty($default)) $default = "title"; if (isset($options['default'])) $default = $options['default']; if (isset($options['title'])) $title = $options['title']; if (value_is_true($options['dropdown'])) { if (isset($Shopp->Cart->data->Category['orderby'])) $default = $Shopp->Cart->data->Category['orderby']; $string .= $title; $string .= '<form action="'.esc_url($_SERVER['REQUEST_URI']).'" method="get" id="shopp-'.$Shopp->Category->slug.'-orderby-menu">'; if (!SHOPP_PERMALINKS) { foreach ($_GET as $key => $value) if ($key != 'shopp_orderby') $string .= '<input type="hidden" name="'.$key.'" value="'.$value.'" />'; } $string .= '<select name="shopp_orderby" class="shopp-orderby-menu">'; $string .= menuoptions($menuoptions,$default,true); $string .= '</select>'; $string .= '</form>'; $string .= '<script type="text/javascript">'; $string .= "jQuery('#shopp-".$Shopp->Category->slug."-orderby-menu select.shopp-orderby-menu').change(function () { this.form.submit(); });"; $string .= '</script>'; } else { if (strpos($_SERVER['REQUEST_URI'],"?") !== false) list($link,$query) = explode("\?",$_SERVER['REQUEST_URI']); $query = $_GET; unset($query['shopp_orderby']); $query = http_build_query($query); if (!empty($query)) $query .= '&'; foreach($menuoptions as $value => $option) { $label = $option; $href = esc_url($link.'?'.$query.'shopp_orderby='.$value); $string .= '<li><a href="'.$href.'">'.$label.'</a></li>'; } } return $string; break;

    Read the article

  • Why does hiberfil.sys come back from the dead on Windows 7?

    - by Corey White
    I have Windows 7 running on a small (40GB) partition, with 4GB ram. This means that the hiberfil.sys file created by Hibernate takes up a significant portion of the available diskspace. I would like to remove it. I am aware that I can disable Hibernate and remove hiberfil.sys by entering powercfg -h off in an elevated command prompt. This works -- the file is immediately removed, and after doing so, the HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Power\HibernateEnabled key is (correctly) set to 0. However, the next time I reboot the PC, hiberfil.sys returns from the dead, Hibernate is reenabled, and that registry key has returned to 1. I'm pretty much at my wits' end with this. Almost everything I can find online related to removing the hiberfil.sys file simply suggests using powercfg to turn off hibernation, and that appears to work for just about everyone. But it just keeps coming back for me! (Like a vampire, sucking up my disk space.) I did find one other thread from someone who seems to have had the same issue, but none of the suggestions there worked for the original poster (or for me). Still, I have tried everything listed there, including: Disabling hybrid sleep Disabling Hibernate through the command prompt, through the Power Options GUI, and through both (in both orders) Manually changing the HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Power\HibernateEnabled key Pretty much everything else I can think of! I do want to reiterate that I have no problem removing the file -- that works great. It just comes back after every reboot. I'm about ready to throw in the towel and just run a script on login to disable Hibernate each time, even though that seems like a crazily hacky "solution" . . . but I was hoping someone here could suggest something else, first. Thanks!

    Read the article

  • Partial string search in boost::multi_index_container

    - by user361699
    I have a struct to store info about persons and multi_index_contaider to store such objects struct person { std::string m_first_name; std::string m_last_name; std::string m_third_name; std::string m_address; std::string m_phone; person(); person(std::string f, std::string l, std::string t = "", std::string a = DEFAULT_ADDRESS, std::string p = DEFAULT_PHONE) : m_first_name(f), m_last_name(l), m_third_name(t), m_address(a), m_phone(p) {} }; typedef multi_index_container , ordered_non_unique, member, member persons_set; operator< and operator<< implementation for person bool operator<(const person &lhs, const person &rhs) { if(lhs.m_last_name == rhs.m_last_name) { if(lhs.m_first_name == rhs.m_first_name) return (lhs.m_third_name < rhs.m_third_name); return (lhs.m_first_name < rhs.m_first_name); } return (lhs.m_last_name < rhs.m_last_name); } std::ostream& operator<<(std::ostream &s, const person &rhs) { s << "Person's last name: " << rhs.m_last_name << std::endl; s << "Person's name: " << rhs.m_first_name << std::endl; if (!rhs.m_third_name.empty()) s << "Person's third name: " << rhs.m_third_name << std::endl; s << "Phone: " << rhs.m_phone << std::endl; s << "Address: " << rhs.m_address << std::endl; return s; } Add several persons into container: person ("Alex", "Johnson", "Somename"); person ("Alex", "Goodspeed"); person ("Petr", "Parker"); person ("Petr", "Goodspeed"); Now I want to find person by lastname (the first member of the second index in multi_index_container) persons_set::nth_index<1::type &names_index = my_set.get<1(); std::pair::type::const_iterator, persons_set::nth_index<1::type::const_iterator n_it = names_index.equal_range("Goodspeed"); std::copy(n_it.first ,n_it.second, std::ostream_iterator(std::cout)); It works great. Both 'Goodspeed' persons are found. Now lets try to find person by a part of a last name: std::pair::type::const_iterator, persons_set::nth_index<1::type::const_iterator n_it = names_index.equal_range("Good"); std::copy(n_it.first ,n_it.second, std::ostream_iterator(std::cout)); This returns nothing, but partial string search works as a charm in std::set. So I can't realize what's the problem. I only wraped strings by a struct. May be operator< implementation? Thanks in advance for any help.

    Read the article

  • How to get distinct results in hibernate with joins and row-based limiting?

    - by Daniel Alexiuc
    I'm trying to implement paging using row-based limiting (for example: setFirstResult(5) and setMaxResults(10)) on a Hibernate Criteria query that has joins to other tables. Understandably, data is getting cut off randomly; and the reason for that is explained here. As a solution, the page suggests using a "second sql select" instead of a join. How can I convert my existing criteria query (which has joins using createAlias()) to use a nested select instead?

    Read the article

  • What other libraries or tools would you add to a Spring/Hibernate stack for improved rapid applicati

    - by CaptainAwesomePants
    My team at work maintains a fairly large webapp written on top of Spring and Hibernate. We're about to start making some fairly large scale changes to the site, and we're enamored with the rapid application development speeds allowed by some other frameworks, like Rails. We haven't really changed our stack much in the last year or two, and I'm wondering what new tools, approaches, and libraries might be out there to help speed up webapp development.

    Read the article

  • Does Hibernate always need a setter when there is a getter?

    - by Marcus
    We have some Hibernate getter methods annotated with both @Column and @Basic. We get an exception if we don't have the corresponding setter. Why is this? In our case we are deriving the value returned from the getter (to get stored in the DB) and the setter has no functional purpose. So we just have an empty method to get around the error condition..

    Read the article

  • Different cache concurrent strategies for root entity and its collection (Hibernate with EHCache)?

    - by grigory
    Given example from Hibernate docs and modifying it so that root level entity (Customer) is read-only while one of its collections (tickets) is read-write: @Entity @Cache(usage = CacheConcurrencyStrategy.READ_ONLY) public class Customer { ... @OneToMany(...) @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) public SortedSet<Ticket> getTickets() { return tickets; } ... } Would collection of tickets get refreshed when accessing customer from cache?

    Read the article

  • what's the best practice to config Hibernate-Spring for multiple database relationship?

    - by nazila
    We have a main mysql database which all of the applications within our organization need the data within this database. How can I config my java web application to use this database with it's specific database when I use Spring and Hibernate within my application? How can I config JPA annotations for example between CONTRACT table within my database and COUNTRY table within our main database? what's the best practice to do this?

    Read the article

  • Is there a way to specify wildcarded region names when using ehcache with hibernate?

    - by bkent314
    When using Ehcache with Hibernate, is there a way to specify region names with wildcards in the ehcache.xml file? For example, to allow for cache settings at the package level (with * as a wildcard indicator): <cache name="com.example.my.package1.*" ... /> <cache name="com.example.my.package2.*" ... /> (Note: The package-level distinction is just an example. My question is to wildcards in the general case.)

    Read the article

< Previous Page | 74 75 76 77 78 79 80 81 82 83 84 85  | Next Page >